C# Class Smrf.NodeXL.Layouts.FruchtermanReingoldLayout

Lays out a graph using the Fruchterman-Reingold layout.
For details on the layout algorithm, see http://www.cs.ubc.ca/rr/proceedings/spe91-95/spe/vol21/issue11/spe060tf.pdf.

If the graph has a metadata key of , only the vertices specified in the value's IVertex collection are laid out and all other vertices are completely ignored.

If the graph has a metadata key of , the previous layout is used as a starting point for the new layout. Otherwise, the locations of all unlocked vertices are randomized at the start of the layout process.

If a vertex has a metadata key of with a value of true, it is included in layout calculations but its own location is left unmodified.

If an edge has a metadata key of , the edge weight is used in the layout calculations. Edges with larger edge weights exert stronger attractive forces on their vertices. If an edge weight is zero or less, the algorithm ignores it and uses a value of 1.0 instead.

Here is sample C# code that uses a to synchronously lay out a graph. using System; using System.Drawing; using Smrf.NodeXL.Core; using Smrf.NodeXL.Layouts; namespace PopulateAndLayOutGraph { class Program { static void Main(string[] args) { // Create a graph. The graph has no visual representation; it is // just a data structure. Graph oGraph = new Graph(GraphDirectedness.Directed); IVertexCollection oVertices = oGraph.Vertices; IEdgeCollection oEdges = oGraph.Edges; // Add three vertices. IVertex oVertexA = oVertices.Add(); oVertexA.Name = "Vertex A"; IVertex oVertexB = oVertices.Add(); oVertexB.Name = "Vertex B"; IVertex oVertexC = oVertices.Add(); oVertexC.Name = "Vertex C"; // Connect the vertices with directed edges. IEdge oEdge1 = oEdges.Add(oVertexA, oVertexB, true); IEdge oEdge2 = oEdges.Add(oVertexB, oVertexC, true); IEdge oEdge3 = oEdges.Add(oVertexC, oVertexA, true); // Lay out the graph within a 100x100 rectangle. This sets the // IVertex.Location property of each vertex. ILayout oLayout = new FruchtermanReingoldLayout(); LayoutContext oLayoutContext = new LayoutContext(new Rectangle(0, 0, 100, 100)); oLayout.LayOutGraph(oGraph, oLayoutContext); // List the results. foreach (IVertex oVertex in oVertices) { Console.WriteLine("The location of {0} is {1}.", oVertex.Name, oVertex.Location); } } } }
Inheritance: LayoutBase
Mostrar archivo Open project: 2014-sed-team3/term-project Class Usage Examples

Protected Properties

Property Type Description
m_fC System.Single
m_iIterations System.Int32

Public Methods

Method Description
AssertValid ( ) : void
FruchtermanReingoldLayout ( ) : System

Initializes a new instance of the FruchtermanReingoldLayout class.

Protected Methods

Method Description
CalculateAttractiveForces ( ICollection edgesToLayOut, System.Single k ) : void
CalculateRepulsiveForces ( ICollection verticesToLayOut, System.Single k ) : void
InitializeMetadata ( IGraph oGraph, ICollection oVerticesToLayOut ) : void
LayOutGraphCore ( IGraph graph, ICollection verticesToLayOut, LayoutContext layoutContext, BackgroundWorker backgroundWorker ) : System.Boolean
RemoveMetadata ( IGraph oGraph, ICollection oVerticesToLayOut ) : void
RestoreTag ( IMetadataProvider oVertexOrEdge ) : void
SaveTag ( IMetadataProvider oVertexOrEdge ) : void
SetUnboundedLocations ( ICollection verticesToLayOut, LayoutContext layoutContext, System.Single fTemperature, System.Boolean bAlsoSetVertexLocations ) : void

Method Details

AssertValid() public method

public AssertValid ( ) : void
return void

CalculateAttractiveForces() protected method

protected CalculateAttractiveForces ( ICollection edgesToLayOut, System.Single k ) : void
edgesToLayOut ICollection
k System.Single
return void

CalculateRepulsiveForces() protected method

protected CalculateRepulsiveForces ( ICollection verticesToLayOut, System.Single k ) : void
verticesToLayOut ICollection
k System.Single
return void

FruchtermanReingoldLayout() public method

Initializes a new instance of the FruchtermanReingoldLayout class.
public FruchtermanReingoldLayout ( ) : System
return System

InitializeMetadata() protected method

protected InitializeMetadata ( IGraph oGraph, ICollection oVerticesToLayOut ) : void
oGraph IGraph
oVerticesToLayOut ICollection
return void

LayOutGraphCore() protected method

protected LayOutGraphCore ( IGraph graph, ICollection verticesToLayOut, LayoutContext layoutContext, BackgroundWorker backgroundWorker ) : System.Boolean
graph IGraph
verticesToLayOut ICollection
layoutContext LayoutContext
backgroundWorker System.ComponentModel.BackgroundWorker
return System.Boolean

RemoveMetadata() protected method

protected RemoveMetadata ( IGraph oGraph, ICollection oVerticesToLayOut ) : void
oGraph IGraph
oVerticesToLayOut ICollection
return void

RestoreTag() protected method

protected RestoreTag ( IMetadataProvider oVertexOrEdge ) : void
oVertexOrEdge IMetadataProvider
return void

SaveTag() protected method

protected SaveTag ( IMetadataProvider oVertexOrEdge ) : void
oVertexOrEdge IMetadataProvider
return void

SetUnboundedLocations() protected method

protected SetUnboundedLocations ( ICollection verticesToLayOut, LayoutContext layoutContext, System.Single fTemperature, System.Boolean bAlsoSetVertexLocations ) : void
verticesToLayOut ICollection
layoutContext LayoutContext
fTemperature System.Single
bAlsoSetVertexLocations System.Boolean
return void

Property Details

m_fC protected_oe property

protected Single,System m_fC
return System.Single

m_iIterations protected_oe property

protected Int32,System m_iIterations
return System.Int32