|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectuchicago.src.sim.gui.AbstractGraphLayout
uchicago.src.sim.gui.LayoutWithDisplay
uchicago.src.sim.gui.KamadaGraphLayout
public class 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 |
|---|
| Fields inherited from class uchicago.src.sim.gui.LayoutWithDisplay |
|---|
display, isEventThread |
| Fields inherited from class uchicago.src.sim.gui.AbstractGraphLayout |
|---|
height, nodeList, update, width |
| Constructor Summary | |
|---|---|
KamadaGraphLayout(int width,
int height)
Creates a KamadaGraphLayout with specified width and height. |
|
KamadaGraphLayout(java.util.List nodes,
int width,
int height)
Creates a KamadaGraphLayout with specified width and height, and list of nodes. setDisplay must be called before calling updateLayout(). |
|
KamadaGraphLayout(java.util.List nodes,
int width,
int height,
DisplaySurface surface,
int updateEveryN)
If the KamadaGraphLayout is passed a display, and a value for updateEveryN, it will call the display's updateDisplay() method on every Nth pass during the layout to provide visual feedback. |
|
| Method Summary | |
|---|---|
void |
actionPerformed(java.awt.event.ActionEvent evt)
Implements the ActionListener interface. |
void |
circleLayout()
Positions nodes on layout in a circle for repeatability. |
void |
setAnimateTransitions(boolean animateTrans)
Sets whether the completed layout (and each component as it is finished) will smoothly transition to its new location. |
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 |
setUpdateEveryN(int updateEveryN)
Sets how frequently the layout will be redrawn during algorithm convergence. |
void |
updateLayout()
Positions the nodes on the layout according to the results of numerous iterations of the Kamada-Kawai spring-embedding algorithm. |
| Methods inherited from class uchicago.src.sim.gui.LayoutWithDisplay |
|---|
setDisplay, updateDisplay |
| Methods inherited from class uchicago.src.sim.gui.AbstractGraphLayout |
|---|
appendToList, appendToList, getHeight, getNodeList, getUpdate, getWidth, setList, setUpdate |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public KamadaGraphLayout(int width,
int height)
width - the width (in pixels) of the displaySurfaceheight - the height (in pixels) of the DisplaySurface
public KamadaGraphLayout(java.util.List nodes,
int width,
int height)
nodes - the list nodes to layout with this KamadaGraphLayoutwidth - the width (in pixels) of the DisplaySurfaceheight - the height (in pixels) of the DisplaySurface
public KamadaGraphLayout(java.util.List nodes,
int width,
int height,
DisplaySurface surface,
int updateEveryN)
nodes - the network to layout.width - the width (pixels) of the display surfaceheight - the height (pixels) of the display surfacesurface - the displaysurface to updateupdateEveryN - determines if/ when layout is redrawn during
algorithm| 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 setAnimateTransitions(boolean animateTrans)
animateTrans - whether to animate transitions between layoutspublic void circleLayout()
public void updateLayout()
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
updateLayout in interface GraphLayoutupdateLayout in class AbstractGraphLayoutpublic void actionPerformed(java.awt.event.ActionEvent evt)
actionPerformed in interface java.awt.event.ActionListeneractionPerformed in class AbstractGraphLayout
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||