nct.visualization.cytoscape.dual
Class SpringEmbeddedLayouter

java.lang.Object
  extended by nct.visualization.cytoscape.dual.SpringEmbeddedLayouter

public class SpringEmbeddedLayouter
extends java.lang.Object

A modified implementation of Kamada and Kawai's spring embedded layout algorithm. The key insight to the dual layout modification of this algorithm is that the homology edges are forced to have very low spring strengths which means that real (compatibility) edges will overpower the homology edges and pull themselves into separate clusters.


Field Summary
protected  double[] anticollisionSpringScalars
           
protected  double[][] anticollisionSpringStrength
           
protected  double averageIterationsPerNode
           
static double[] DEFAULT_ANTICOLLISION_SPRING_SCALARS
           
static double DEFAULT_ANTICOLLISION_SPRING_STRENGTH
           
static double DEFAULT_AVERAGE_ITERATIONS_PER_NODE
           
static double DEFAULT_DISCONNECTED_NODE_DISTANCE_SPRING_REST_LENGTH
           
static double DEFAULT_DISCONNECTED_NODE_DISTANCE_SPRING_STRENGTH
           
static double DEFAULT_NODE_DISTANCE_REST_LENGTH_CONSTANT
           
static double[] DEFAULT_NODE_DISTANCE_SPRING_SCALARS
           
static double DEFAULT_NODE_DISTANCE_STRENGTH_CONSTANT
           
static int DEFAULT_NUM_LAYOUT_PASSES
           
protected  double disconnectedNodeDistanceSpringRestLength
           
protected  double disconnectedNodeDistanceSpringStrength
           
protected  int edgeCount
           
protected  giny.view.GraphView graphView
           
static double HOMOLOGY_MULTIPLIER
           
protected  NodePairSet homologyPairSet
           
protected  int layoutPass
           
protected  java.util.HashMap<giny.model.Node,java.lang.Integer> node2Index
           
protected  java.util.HashMap node2Species
           
protected  int nodeCount
           
protected  double nodeDistanceRestLengthConstant
           
protected  double[][] nodeDistanceSpringRestLengths
           
protected  double[] nodeDistanceSpringScalars
           
protected  double[][] nodeDistanceSpringStrengths
           
protected  double nodeDistanceStrengthConstant
           
protected  int numLayoutPasses
           
 
Constructor Summary
SpringEmbeddedLayouter(giny.view.GraphView graph_view, java.util.HashMap node2Species, NodePairSet homologyPairSet)
           
 
Method Summary
protected  int[][] calculateNodeDistances(java.util.List nodesList, giny.model.GraphPerspective network)
           
protected  nct.visualization.cytoscape.dual.SpringEmbeddedLayouter.PartialDerivatives calculatePartials(nct.visualization.cytoscape.dual.SpringEmbeddedLayouter.PartialDerivatives partials, java.util.List partials_list, nct.visualization.cytoscape.dual.SpringEmbeddedLayouter.PotentialEnergy potential_energy, boolean reversed)
          If partials_list is given, adjust all partials (bidirectional) for the current location of the given partials and return the new furthest node's partials.
 void doLayout()
           
 giny.view.GraphView getGraphView()
           
protected  int getNodeViewIndex(giny.view.NodeView n)
           
protected  nct.visualization.cytoscape.dual.SpringEmbeddedLayouter.PartialDerivatives moveNode(nct.visualization.cytoscape.dual.SpringEmbeddedLayouter.PartialDerivatives partials, java.util.List partials_list, nct.visualization.cytoscape.dual.SpringEmbeddedLayouter.PotentialEnergy potential_energy)
          Move the node with the given partials and adjust all partials in the given List to reflect that move, and adjust the potential energy too.
 void setGraphView(giny.view.GraphView new_graph_view)
           
protected  void setupAntiCollisionSprings()
           
protected  void setupForLayoutPass()
          Called at the beginning of each layoutPass iteration.
protected  void setupNodeDistanceSprings()
           
protected  void simpleMoveNode(nct.visualization.cytoscape.dual.SpringEmbeddedLayouter.PartialDerivatives partials)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_NUM_LAYOUT_PASSES

public static final int DEFAULT_NUM_LAYOUT_PASSES
See Also:
Constant Field Values

DEFAULT_AVERAGE_ITERATIONS_PER_NODE

public static final double DEFAULT_AVERAGE_ITERATIONS_PER_NODE
See Also:
Constant Field Values

DEFAULT_NODE_DISTANCE_SPRING_SCALARS

public static final double[] DEFAULT_NODE_DISTANCE_SPRING_SCALARS

DEFAULT_NODE_DISTANCE_STRENGTH_CONSTANT

public static final double DEFAULT_NODE_DISTANCE_STRENGTH_CONSTANT
See Also:
Constant Field Values

DEFAULT_NODE_DISTANCE_REST_LENGTH_CONSTANT

public static final double DEFAULT_NODE_DISTANCE_REST_LENGTH_CONSTANT
See Also:
Constant Field Values

DEFAULT_DISCONNECTED_NODE_DISTANCE_SPRING_STRENGTH

public static final double DEFAULT_DISCONNECTED_NODE_DISTANCE_SPRING_STRENGTH
See Also:
Constant Field Values

DEFAULT_DISCONNECTED_NODE_DISTANCE_SPRING_REST_LENGTH

public static final double DEFAULT_DISCONNECTED_NODE_DISTANCE_SPRING_REST_LENGTH
See Also:
Constant Field Values

HOMOLOGY_MULTIPLIER

public static double HOMOLOGY_MULTIPLIER

DEFAULT_ANTICOLLISION_SPRING_SCALARS

public static final double[] DEFAULT_ANTICOLLISION_SPRING_SCALARS

DEFAULT_ANTICOLLISION_SPRING_STRENGTH

public static final double DEFAULT_ANTICOLLISION_SPRING_STRENGTH
See Also:
Constant Field Values

numLayoutPasses

protected int numLayoutPasses

averageIterationsPerNode

protected double averageIterationsPerNode

nodeDistanceSpringScalars

protected double[] nodeDistanceSpringScalars

nodeDistanceStrengthConstant

protected double nodeDistanceStrengthConstant

nodeDistanceRestLengthConstant

protected double nodeDistanceRestLengthConstant

disconnectedNodeDistanceSpringStrength

protected double disconnectedNodeDistanceSpringStrength

disconnectedNodeDistanceSpringRestLength

protected double disconnectedNodeDistanceSpringRestLength

nodeDistanceSpringStrengths

protected double[][] nodeDistanceSpringStrengths

nodeDistanceSpringRestLengths

protected double[][] nodeDistanceSpringRestLengths

anticollisionSpringScalars

protected double[] anticollisionSpringScalars

anticollisionSpringStrength

protected double[][] anticollisionSpringStrength

graphView

protected giny.view.GraphView graphView

nodeCount

protected int nodeCount

edgeCount

protected int edgeCount

layoutPass

protected int layoutPass

node2Species

protected java.util.HashMap node2Species

homologyPairSet

protected NodePairSet homologyPairSet

node2Index

protected java.util.HashMap<giny.model.Node,java.lang.Integer> node2Index
Constructor Detail

SpringEmbeddedLayouter

public SpringEmbeddedLayouter(giny.view.GraphView graph_view,
                              java.util.HashMap node2Species,
                              NodePairSet homologyPairSet)
Parameters:
node2Species - a hashmap which maps from a node to a species number
Method Detail

setGraphView

public void setGraphView(giny.view.GraphView new_graph_view)

getGraphView

public giny.view.GraphView getGraphView()

getNodeViewIndex

protected int getNodeViewIndex(giny.view.NodeView n)

doLayout

public void doLayout()

setupForLayoutPass

protected void setupForLayoutPass()
Called at the beginning of each layoutPass iteration.


setupAntiCollisionSprings

protected void setupAntiCollisionSprings()

calculateNodeDistances

protected int[][] calculateNodeDistances(java.util.List nodesList,
                                         giny.model.GraphPerspective network)

setupNodeDistanceSprings

protected void setupNodeDistanceSprings()

calculatePartials

protected nct.visualization.cytoscape.dual.SpringEmbeddedLayouter.PartialDerivatives calculatePartials(nct.visualization.cytoscape.dual.SpringEmbeddedLayouter.PartialDerivatives partials,
                                                                                                       java.util.List partials_list,
                                                                                                       nct.visualization.cytoscape.dual.SpringEmbeddedLayouter.PotentialEnergy potential_energy,
                                                                                                       boolean reversed)
If partials_list is given, adjust all partials (bidirectional) for the current location of the given partials and return the new furthest node's partials. Otherwise, just adjust the given partials (using the graphView's nodeViewsIterator), and return it. If reversed is true then partials_list must be provided and all adjustments made by a non-reversed call (with the same partials with the same graphNodeView at the same location) will be undone. Complexity is O( #Nodes ).


moveNode

protected nct.visualization.cytoscape.dual.SpringEmbeddedLayouter.PartialDerivatives moveNode(nct.visualization.cytoscape.dual.SpringEmbeddedLayouter.PartialDerivatives partials,
                                                                                              java.util.List partials_list,
                                                                                              nct.visualization.cytoscape.dual.SpringEmbeddedLayouter.PotentialEnergy potential_energy)
Move the node with the given partials and adjust all partials in the given List to reflect that move, and adjust the potential energy too.

Returns:
the PartialDerivatives of the furthest node after the move.

simpleMoveNode

protected void simpleMoveNode(nct.visualization.cytoscape.dual.SpringEmbeddedLayouter.PartialDerivatives partials)