|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.uci.ics.jung.visualization.AbstractLayout com.hp.hpl.guess.layout.KamadaGraphLayout
Positions network nodes according to the Kamada-Kawai algorithm. The Kamada-Kawai graph layout class attempts to position nodes on the space so that the geometric (Euclidean) distance between them is as close as possible to the graph-theoretic (path) distance between them. the x and y coordinates of the nodes will be modified by the layout.
The KamadaGraphLayout implements the ActionListener interface to
interrupt the layout. This breaks out of the algorithm
implementation as soon as possible, but will rescale the display if
appropriate. You can have the KamadaGraphLayout listener for RePast
toolbar button presses by including something like the following
code inside your model class.
This will cause the KamadaGraphLayout graphLayout to interrupt its layout
whenever stop, pause, or exit is pressed.
graphLayout = new KamadaGraphLayout(...);
Controller c = (Controller)getController();
c.addStopListener(graphLayout);
c.addPauseListener(graphLayout);
c.addExitListener(graphLayout);
Note The KamadaGraphLayout is quite slow. It is not meant as a "true" visualization tool, but rather is intended only to provide the modeler with "sense" of the network. Real analysis and visualization should be done in a tool like Pajek.
Field Summary | |
boolean |
done
|
Constructor Summary | |
KamadaGraphLayout(Graph g,
boolean firstLayout,
int width,
int height)
|
Method Summary | |
void |
actionPerformed(ActionEvent evt)
Implements the ActionListener interface. |
void |
advancePositions()
Positions the nodes on the layout according to the results of numerous iterations of the Kamada-Kawai spring-embedding algorithm. |
void |
circleLayout()
Positions nodes on layout in a circle for repeatability. |
Coordinates |
getCoordinates(Node v)
|
int |
getHeight()
Gets the height of the area on which to layout the graph. |
int |
getWidth()
Gets the width of the area on which to layout the graph. |
double |
getX(Vertex n)
|
double |
getY(Vertex n)
|
boolean |
incrementsAreDone()
|
void |
initialize_local_vertex(Vertex v)
|
void |
initialize_local()
|
boolean |
isIncremental()
|
void |
setCircleLayout(boolean eachTime)
Sets whether circleLayout will be called to arrange nodes before starting each layout. |
void |
setMaxPasses(int passes)
Sets the maximum number of passes the inner loop of the KK algorithm will execute. |
void |
setMinEpsilon(double energy)
Sets the minimum "spring" energy which the layout attempts to achieve. |
void |
setPad(int p)
Sets the number of pixels to shrink the effective window by. |
void |
setRescaleLayout(boolean rescale)
Sets whether the completed layout will be resized to exactly fill the display window. |
void |
setSpringConst(double spring)
Sets the "springiness" of the imaginary springs connecting the nodes. |
void |
setUpdate(boolean doUpdate)
|
void |
setUpdateEveryN(int updateEveryN)
Sets how frequently the layout will be redrawn during algorithm convergence. |
Methods inherited from class edu.uci.ics.jung.visualization.AbstractLayout |
addChangeListener, applyFilter, dontMove, fireStateChanged, forceMove, getBaseKey, getChangeListeners, getCoordinates, getCurrentSize, getEdge, getEdge, getGraph, getLocation, getStatus, getVertex, getVertex, getVertexIterator, getVisibleEdges, getVisibleVertices, initialize, initialize, lockVertex, removeChangeListener, resize, restart, unlockVertex |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public boolean done
Constructor Detail |
public KamadaGraphLayout(Graph g, boolean firstLayout, int width, int height)
Method Detail |
public void setPad(int p)
p
- the number of pixels to inset bypublic void setUpdateEveryN(int updateEveryN)
updateEveryN
- the N for determining wether to update on the
Nth passpublic void setMinEpsilon(double energy)
energy
- the value for the minimum epsilonpublic void setSpringConst(double spring)
spring
- the value for the spring constant in the algorithmpublic void setMaxPasses(int passes)
passes
- the maximum number of time the inner loop will
execute.public void setCircleLayout(boolean eachTime)
eachTime
- true = always call circleLayoutpublic void setRescaleLayout(boolean rescale)
rescale
- whether to rescale the layoutpublic void circleLayout()
public void advancePositions()
Note: In the current implementation the layout may not always converge! however, the maxPasses parameter can be set lower to interrupt cycling layouts. Also has not been tested/ implemented on weighted graphs. The Kamada-Kawai algorithm was not intended to run on disconnected graphs (graphs with multiple components. The kludgy solution implemented here is to run the algorithm independently on each of the components (of size > 1). This is somewhat unsatisfactory as the components will often overlap.
The KK algorithm is relatively slow, especially on the first round. However, it often discovers layouts of regularly structured graphs which are "better" and more repeatable than the Fruchmen-Reingold technique. Implementation of the numerics of the Newton-Raphson method follows Shawn Lorae Stutzman, Auburn University, 12/12/96 http://mathcs.mta.ca/research/rosebrugh/gdct/javasource.htm
Kamada, Tomihisa and Satoru Kawai (1989) "An Algorithm for Drawing Undirected Graphs" Information Processing Letters 31:7-15
public void actionPerformed(ActionEvent evt)
public int getHeight()
public int getWidth()
public void setUpdate(boolean doUpdate)
public double getX(Vertex n)
public double getY(Vertex n)
public Coordinates getCoordinates(Node v)
public boolean incrementsAreDone()
public void initialize_local_vertex(Vertex v)
public void initialize_local()
public boolean isIncremental()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |