C# Класс 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); } } } }
Наследование: LayoutBase
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
m_fC System.Single
m_iIterations System.Int32

Открытые методы

Метод Описание
AssertValid ( ) : void
FruchtermanReingoldLayout ( ) : System

Initializes a new instance of the FruchtermanReingoldLayout class.

Защищенные методы

Метод Описание
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

Описание методов

AssertValid() публичный Метод

public AssertValid ( ) : void
Результат void

CalculateAttractiveForces() защищенный Метод

protected CalculateAttractiveForces ( ICollection edgesToLayOut, System.Single k ) : void
edgesToLayOut ICollection
k System.Single
Результат void

CalculateRepulsiveForces() защищенный Метод

protected CalculateRepulsiveForces ( ICollection verticesToLayOut, System.Single k ) : void
verticesToLayOut ICollection
k System.Single
Результат void

FruchtermanReingoldLayout() публичный Метод

Initializes a new instance of the FruchtermanReingoldLayout class.
public FruchtermanReingoldLayout ( ) : System
Результат System

InitializeMetadata() защищенный Метод

protected InitializeMetadata ( IGraph oGraph, ICollection oVerticesToLayOut ) : void
oGraph IGraph
oVerticesToLayOut ICollection
Результат void

LayOutGraphCore() защищенный Метод

protected LayOutGraphCore ( IGraph graph, ICollection verticesToLayOut, LayoutContext layoutContext, BackgroundWorker backgroundWorker ) : System.Boolean
graph IGraph
verticesToLayOut ICollection
layoutContext LayoutContext
backgroundWorker System.ComponentModel.BackgroundWorker
Результат System.Boolean

RemoveMetadata() защищенный Метод

protected RemoveMetadata ( IGraph oGraph, ICollection oVerticesToLayOut ) : void
oGraph IGraph
oVerticesToLayOut ICollection
Результат void

RestoreTag() защищенный Метод

protected RestoreTag ( IMetadataProvider oVertexOrEdge ) : void
oVertexOrEdge IMetadataProvider
Результат void

SaveTag() защищенный Метод

protected SaveTag ( IMetadataProvider oVertexOrEdge ) : void
oVertexOrEdge IMetadataProvider
Результат void

SetUnboundedLocations() защищенный Метод

protected SetUnboundedLocations ( ICollection verticesToLayOut, LayoutContext layoutContext, System.Single fTemperature, System.Boolean bAlsoSetVertexLocations ) : void
verticesToLayOut ICollection
layoutContext LayoutContext
fTemperature System.Single
bAlsoSetVertexLocations System.Boolean
Результат void

Описание свойств

m_fC защищенное свойство

protected Single,System m_fC
Результат System.Single

m_iIterations защищенное свойство

protected Int32,System m_iIterations
Результат System.Int32