Some of the most flexible algorithms for calculating layouts of simple undirected graphs
belong to a class known as force-directed algorithms.
Also known as spring embedders,
such algorithms calculate the layout of a graph using only information contained within
the structure of the graph itself, rather than relying on domain-specific knowledge.
Graphs
drawn with these algorithms tend to be aesthetically pleasing, exhibit symmetries, and tend
to produce crossing-free layouts for planar graphs
The file Graph2.py , implements the following preliminary algorithm for force directed graph drawing :
algorithm SPRING(G:graph);
place vertices of G in random locations;
repeat M times
calculate the force on each vertex;
move the vertex c4 ∗ (force on vertex)
draw graph on CRT or plotter.
Attractive Force is computed by using : Hooke's Law
Repulsive Forces are computed by using : Coulomb's Law
Outputs