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
Afficher le fichier Open project: 2014-sed-team3/term-project Class Usage Examples

Protected Properties

Свойство Type Description
m_fC System.Single
m_iIterations System.Int32

Méthodes publiques

Méthode Description
AssertValid ( ) : void
FruchtermanReingoldLayout ( ) : System

Initializes a new instance of the FruchtermanReingoldLayout class.

Méthodes protégées

Méthode 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 méthode

public AssertValid ( ) : void
Résultat void

CalculateAttractiveForces() protected méthode

protected CalculateAttractiveForces ( ICollection edgesToLayOut, System.Single k ) : void
edgesToLayOut ICollection
k System.Single
Résultat void

CalculateRepulsiveForces() protected méthode

protected CalculateRepulsiveForces ( ICollection verticesToLayOut, System.Single k ) : void
verticesToLayOut ICollection
k System.Single
Résultat void

FruchtermanReingoldLayout() public méthode

Initializes a new instance of the FruchtermanReingoldLayout class.
public FruchtermanReingoldLayout ( ) : System
Résultat System

InitializeMetadata() protected méthode

protected InitializeMetadata ( IGraph oGraph, ICollection oVerticesToLayOut ) : void
oGraph IGraph
oVerticesToLayOut ICollection
Résultat void

LayOutGraphCore() protected méthode

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

RemoveMetadata() protected méthode

protected RemoveMetadata ( IGraph oGraph, ICollection oVerticesToLayOut ) : void
oGraph IGraph
oVerticesToLayOut ICollection
Résultat void

RestoreTag() protected méthode

protected RestoreTag ( IMetadataProvider oVertexOrEdge ) : void
oVertexOrEdge IMetadataProvider
Résultat void

SaveTag() protected méthode

protected SaveTag ( IMetadataProvider oVertexOrEdge ) : void
oVertexOrEdge IMetadataProvider
Résultat void

SetUnboundedLocations() protected méthode

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

Property Details

m_fC protected_oe property

protected Single,System m_fC
Résultat System.Single

m_iIterations protected_oe property

protected Int32,System m_iIterations
Résultat System.Int32