Applet
GRAPH LAYOUT
 
 
PRESENTATION
 

This applet illustrates a method that attempts to improve the layout of a graph. This applet is highly inspired from the demonstration applet called GraphLayout in Java 2 SDK of Sun Microsystems. The main idea of the algorithm is to start with random coordinates for the nodes of the graph and simulate forces between this nodes in order to reach a balance that is supposed to be a good layout for the graph. The result is quite good for small graphs, but the method is generally inefficient for large graphs. Briefly, each arc of the graph creates an attraction force between its two extremities that grows with its length. On the contrary, between every pair of nodes is a repulsion force that grows when the distance between the nodes decreases.

If you are interested on this applet, look at the page .

 
EXAMPLE
 

To use this applet, you have to indicate the size of the layout and to describe the structure of the graph.

The structure of the graph is specified by a string of characters in the parameter graph. It simply lists the arcs of the graph. For instance, the graph above will be specified as follows.

1-2,2-3,3-4,4-5,5-6,6-7,7-8,8-1,3-5,
5-7,5-9,0-1,0-2,0-3,0-4,0-5,0-6,0-7,0-8

Be careful to number the nodes from 0 and to avoid jumps in the numbering. The applet can then attempt to find a good layout for the graph.

Click to restart.
 
 
SOURCE CODE
 

Here is the source code of the applet: GraphLayout.java.

 
DOWNLOADING
 

Click here to download the applet and its source code.