Spring Graph Layout Method
Options
Description
Examples
constantonly=truefalse
If the constantonly=true option is given then a pure constant repulsive force for the vertices. This layout style is equivalent to spring for Maple 15 and earlier versions.
initial=Array, Matrix, list, name, or string
The initial option is used to specify the initial vertex location before solving the spring system. By default it is random and uses randomly chosen points. The name structured will start the vertex in a structured grid. The names of other layout methods can be used to use their previously computed output stored in the Graph data structure. Finally, a list, Array, or Matrix of point locations may be given.
iterations=posint
The maximum number of iterations that will be used to solve the ODE system. Default is 20000. The actual number of iterations used will be displayed if infolevel[GraphTheory] is set to 2 or higher.
legacy=truefalse
If set to true, an older version of the spring code will be called rather than the compiled C code used by default. This code just supports the constant force only model and doesn't support the iterations option.
frames=posint
The number of frames of animation returned from the layout. The default is 50. If the option animate was not provided to DrawGraph this option will be ignored.
The spring layout method is so named because it simulates a physical model where the vertices are modeled as protons repelling each other and the edges are modeled as springs attracting adjacent vertices. This leads to a dense system of nonlinear ODEs to be solved and so this option becomes quite expensive beyond 100 vertices. At present the spring option requires that the graph be connected.
This layout method works in two and three dimensions and for animations.
with⁡GraphTheory:
with⁡SpecialGraphs:
with⁡RandomGraphs:
G≔Graph⁡undirected,1,2,1,4,2,3,3,4
G≔Graph 1: an undirected graph with 4 vertices and 4 edge(s)
DrawGraph⁡G,layout=spring
The following use animations to illustrate using different initial points
P≔PetersenGraph⁡
P≔Graph 2: an undirected graph with 10 vertices and 15 edge(s)
DrawGraph⁡P,layout=spring,animate
DrawGraph⁡P,layout=spring,animate,layoutoptions=initial=structured,frames=15
DrawGraph⁡P,layout=spring,animate=15
H≔HypercubeGraph⁡3
H≔Graph 3: an undirected graph with 8 vertices and 12 edge(s)
DrawGraph⁡H,layout=spring,dimension=3
See Also
GraphTheory[DrawGraph]
Download Help Document