"SpringEmbedding" (Graph Layout Method)
"SpringEmbedding" (Graph Layout Method)
- Vertex layout for GraphLayout.
- Use spring embedding to lay out vertices of a graph.
Details & Suboptions
- The spring embedding is a graph-drawing technique to position vertices of a graph so that they minimize the mechanical energy when each edge corresponds to a spring.
- The spring embedding is typically used to lay out regular structured graphs.
- The layout xi of the vertices i of the graph is calculated by minimizing the energy function
-
.
is the graph distance between vertex i and j and
is the relative spring length.- Vertices can be embedded in
. - The following graph parameters can be given:
-
"EdgeWeighted" whether to use edge weights - Possible settings to control the energy minimization process include:
-
"EnergyControl" how the energy function is controlled during minimization "InferentialDistance" cutoff distance for inference from faraway vertices "MaxIteration" maximum number of iterations "RandomSeed" seed for the random generator for initial vertex placement "StepControl" how step lengths are modified during energy minimization "StepLength" initial step length used in moving the vertices "Tolerance" tolerance used in terminating the process - Possible settings to control the layout include:
-
"Rotation" Automatic layout rotation
Examples
open all close allBasic Examples (2)
Place vertices so that they minimize mechanical energy when each edge corresponds to a spring:
Graph[{114, 115, 116, 25, 26, 213, 37, 314, 319, 48, 415, 420, 511, 519, 612, 620, 711, 716, 812, 816, 910, 914, 917, 1015, 1018, 1112, 1317, 1318, 1719, 1820}, GraphLayout -> "SpringEmbedding"]"SpringEmbedding" works best for regular structured graphs:
Graph[GraphData[{"GeneralizedPetersen", {9, 2}}, "EdgeRules"], GraphLayout -> "SpringEmbedding"]Options (9)
"EdgeWeighted" (1)
With the setting "EdgeWeighted"True, edge weights are used:
edge = RandomInteger[#]# + 1& /@ Range[0, 10];
weight = RandomInteger[{1, 5}, 11];Graph[edge, EdgeWeight -> weight, GraphLayout -> {"SpringEmbedding", "EdgeWeighted" -> #}]& /@ {True, False}"EnergyControl" (1)
Use the option "EnergyControl"e to specify limitations on the total energy of the system during minimization:
edge = RandomInteger[#]# + 1& /@ Range[0, 30];Graph[edge, {GraphLayout -> {"SpringEmbedding", "EnergyControl" -> #}}]& /@ {Automatic, "Monotonic", "NonMonotonic"}"InferentialDistance" (1)
Use "InferentialDistance"d to specify a cutoff distance beyond which the interaction between vertices is assumed to be nonexistent:
edge = RandomInteger[#]# + 1& /@ Range[0, 30];Graph[edge, GraphLayout -> {"SpringEmbedding", "InferentialDistance" -> #}]& /@ {Automatic, .5, 2}"MaxIteration" (1)
"RandomSeed" (1)
"StepControl" (1)
Use "StepControl"method to define how step length is modified during energy minimization:
edge = RandomInteger[#]# + 1& /@ Range[0, 30];Graph[edge, GraphLayout -> {"SpringEmbedding", "StepControl" -> #}]& /@ {Automatic, "Monotonic", "NonMonotonic", "StrictlyMonotonic"}