Spring Graph Layout Method - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


Spring Graph Layout Method

 

Options

Description

Examples

Options

• 

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.

Description

• 

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.

Examples

withGraphTheory:

withSpecialGraphs:

withRandomGraphs:

GGraphundirected,1,2,1,4,2,3,3,4

GGraph 1: an undirected graph with 4 vertices and 4 edge(s)

(1)

DrawGraphG,layout=spring

The following use animations to illustrate using different initial points

PPetersenGraph

PGraph 2: an undirected graph with 10 vertices and 15 edge(s)

(2)

DrawGraphP,layout=spring,animate

DrawGraphP,layout=spring,animate,layoutoptions=initial=structured,frames=15

DrawGraphP,layout=spring,animate=15

HHypercubeGraph3

HGraph 3: an undirected graph with 8 vertices and 12 edge(s)

(3)

DrawGraphH,layout=spring,dimension=3

See Also

GraphTheory[DrawGraph]