[IoId("00000000-829a-4b06-a994-bd151aeb0e37")] public sealed class Graph : IStorable, IEquatable<Graph>, IComparable<Graph>
Represents an immutable graph.

Constructors

Graph

#
public Graph(IReader reader)
reader (IReader)

Graph

#
public Graph(Nodes nodes, Edges edges)
Create a graph from its constituent collections. It is often difficult to set up the data correctly from scratch, consider using one of the static 'Create' methods instead of this constructor.
nodes (Nodes)
edges (Edges)

Properties

Cycles

#
public Cycles Cycles { get; }
Gets a cached object for finding cycles in this graph.

DisconnectedSubgraphs

#
public IEnumerable<Graph> DisconnectedSubgraphs { get; }
Enumerate over all disconnected subgraphs that make up this graph.

Edges

#
public Edges Edges { get; }
Gets the edges of this graph.

Length

#
public double Length { get; }
Gets the combined length of all edges.

Nodes

#
public Nodes Nodes { get; }
Gets the nodes of this graph.

Methods

CompareTo

#
public int CompareTo(Graph other)
other (Graph)

Create

#
public static Graph Create(IEnumerable<(Point3d location, MetaData attributes)> nodes, IEnumerable<(int a, int b, MetaData attributes)> edges)
Create a graph from nodes and edges with attributes.
nodes (IEnumerable<(Point3d location, MetaData attributes)>)
edges (IEnumerable<(int a, int b, MetaData attributes)>)

Create

#
public static Graph Create(IEnumerable<Point3d> nodes, IEnumerable<(int a, int b)> edges)
Create a graph from nodes and edges without any attributes.
nodes (IEnumerable<Point3d>)
edges (IEnumerable<(int a, int b)>)

CreateComplete

#
public static Graph CreateComplete(Twig<Point3d> twig, bool upwards, bool downwards, MetaData edgeAttributes = null)
Create a graph by connecting all nodes with all other nodes.
twig (Twig<Point3d>)Points to connect.
upwards (bool)If true, points with lower indices will be connected to points with higher indices.
downwards (bool)Is true, points with higher indices will be connected to points with lower indices.
edgeAttributes (MetaData = null)Attributes to assign to edges.

CreateFromConvexHull2d

#
public static Graph CreateFromConvexHull2d(Twig<Point3d> twig, bool connectInterior, Plane plane = default(Plane), MetaData hullNodeAttributes = null, MetaData interiorNodeAttributes = null, MetaData hullEdgeAttributes = null, MetaData interiorEdgeAttributes = null)
Create a graph based on a 2D convex hull.
twig (Twig<Point3d>)
connectInterior (bool)If true, points on the interior of the hull are included based on a minimum spanning growth.
plane (Plane = null)Plane for convex hull.
hullNodeAttributes (MetaData = null)Attributes for nodes on the hull.
interiorNodeAttributes (MetaData = null)Atributes for nodes on the interior.
hullEdgeAttributes (MetaData = null)Attributes for edges on the hull.
interiorEdgeAttributes (MetaData = null)Attributes for edges on the interior.

CreateFromConvexHull3d

#
public static Graph CreateFromConvexHull3d(Twig<Point3d> twig, bool connectInterior, MetaData hullNodeAttributes = null, MetaData interiorNodeAttributes = null, MetaData hullEdgeAttributes = null, MetaData interiorEdgeAttributes = null)
Create a graph based on a 3D convex hull.
twig (Twig<Point3d>)
connectInterior (bool)If true, points on the interior of the hull are included based on a minimum spanning growth.
hullNodeAttributes (MetaData = null)Attributes for nodes on the hull.
interiorNodeAttributes (MetaData = null)Atributes for nodes on the interior.
hullEdgeAttributes (MetaData = null)Attributes for edges on the hull.
interiorEdgeAttributes (MetaData = null)Attributes for edges on the interior.

CreateFromMesh

#
public static Graph CreateFromMesh(Mesh mesh, MetaData interiorEdges = null, MetaData creaseEdges = null, MetaData nakedEdges = null)
Create a graph using the vertices and n-gon edges of a mesh.
mesh (Mesh)
interiorEdges (MetaData = null)
creaseEdges (MetaData = null)
nakedEdges (MetaData = null)

CreateFromNeighbourhood

#
public static Graph CreateFromNeighbourhood(Twig<Point3d> twig, int maxNeighbours, double minimumDistance, double maximumDistance)
Create a graph by connecting points to their nearest neighbours.
twig (Twig<Point3d>)Points to connect.
maxNeighbours (int)Maximum number of neighbours to connect.
minimumDistance (double)Minimum distance between neighbours.
maximumDistance (double)Maximum distance between neighbours.

CreateFromSpanningTree

#
public static Graph CreateFromSpanningTree(Twig<Point3d> twig)
Create a spanning tree graph from a set of points. Note that spanning trees are usually not unique.
twig (Twig<Point3d>)

CreateFromTesselation

#
public static Graph CreateFromTesselation(Twig<Point3d> twig, Plane plane = default(Plane))
Create a graph from a delaunay triangulation.
twig (Twig<Point3d>)
plane (Plane = null)

CreateOrthogonal

#
public static Graph CreateOrthogonal(int rows, int columns, bool cyclicalRows, bool cyclicalColumns, Func<RC, Point3d> nodePosition = null, Func<RC, MetaData> nodeAttributes = null, Func<RC, RC, MetaData> edgeAttributes = null)
Create an orthogonal graph with row and column connections.
rows (int)
columns (int)
cyclicalRows (bool)
cyclicalColumns (bool)
nodePosition (Func<RC, Point3d> = null)
nodeAttributes (Func<RC, MetaData> = null)
edgeAttributes (Func<RC, RC, MetaData> = null)

Deform

#
public Graph Deform(SpaceMorph deform)
Apply a non-linear transformation to this graph.
deform (SpaceMorph)

DumpToRhino

#
public void DumpToRhino()

Equals

#
public bool Equals(Graph other)
other (Graph)

Equals

#
public override bool Equals(object obj)
obj (object)
Object.Equals

FindCheapestCosts

#
public double[] FindCheapestCosts(int start, double[] edgeCosts, double[] reverseCosts, double[] nodeCosts)
Find the cost of the cheapest route from one node to every other node.
start (int)Index of the node to start at.
edgeCosts (double[])Cost of travelling each edge from its start to its end node. Infinite or NaN costs make an edge impassable.
reverseCosts (double[])Optional cost of travelling each two-way edge from its end to its start node. If null, two-way edges cost the same in both directions.
nodeCosts (double[])Optional cost of passing through each node. Infinite or NaN costs make a node impassable, though it can still be the start or the end.
The cost per node, positive infinity for nodes which cannot be reached.

FindCheapestRoute

#
public Route FindCheapestRoute(int start, int end, double[] edgeCosts, double[] reverseCosts, double[] nodeCosts, out double cost)
Find the cheapest route between two nodes.
start (int)Index of the node to start at.
end (int)Index of the node to end at.
edgeCosts (double[])Cost of travelling each edge from its start to its end node. Infinite or NaN costs make an edge impassable.
reverseCosts (double[])Optional cost of travelling each two-way edge from its end to its start node. If null, two-way edges cost the same in both directions.
nodeCosts (double[])Optional cost of passing through each node. Infinite or NaN costs make a node impassable, though it can still be the start or the end.
cost (out double)Total cost of the route, or positive infinity if the end cannot be reached.
The cheapest route, or null if the end cannot be reached.

FindMinimumSpanningTree

#
public static (int, int)[] FindMinimumSpanningTree(Point3d[] points, (int, int)[] initialEdges = null)
A not very performant implementation of a minimum-spanning-tree finder.
points (Point3d[])Points to connect.
initialEdges ((int, int)[] = null)Optional initial edge setup.
Collection of edges describing the minimum spanning tree.

FindMinimumSpanningTree

#
public static (int, int)[] FindMinimumSpanningTree(Point3d[] points)
A not very performant implementation of a minimum-spanning-tree finder.
points (Point3d[])Points to connect.
Collection of edges describing the minimum spanning tree.

Format

#
public string Format(int maxNodes = 2147483647, int maxEdges = 2147483647, bool includeAttributes = false, NumberFormat format = null)
Format this graph as a block of text.
maxNodes (int = 2147483647)
maxEdges (int = 2147483647)
includeAttributes (bool = false)
format (NumberFormat = null)

GetHashCode

#
public override int GetHashCode()

MakeDirected

#
public Graph MakeDirected()
Make all edges one-way.

MakeUndirected

#
public Graph MakeUndirected()
Make all edges two-way.

Merge

#
public static Graph Merge(params Graph[] graphs)
Merge a set of graphs into a single one.
graphs (params Graph[])Graphs to merge.
Merged graph.

RemoveEdges

#
public Graph RemoveEdges(bool[] delete)
Create a new graph without the indicated edges.
delete (bool[])

RemoveEdges

#
public Graph RemoveEdges(int[] edgeIndices)
Create a new graph without the indicated edges.
edgeIndices (int[])

RemoveNodes

#
public Graph RemoveNodes(bool[] delete)
Create a new graph without the indicated nodes. This may also affect the edges, as edges may not be left dangling.
delete (bool[])

RemoveNodes

#
public Graph RemoveNodes(int[] nodeIndices)
Create a new graph without the indicated nodes. This may also affect the edges, as edges may not be left dangling.
nodeIndices (int[])

Store

#
public void Store(IWriter writer)
writer (IWriter)
Store

ToString

#
public override string ToString()
Object.ToString

Transform

#
public Graph Transform(Transform transform)
Apply a linear transformation to this graph.
transform (Transform)

WithoutEdgeAttributes

#
public Graph WithoutEdgeAttributes()
Create a new graph without any edge attributes.

WithoutNodeAttributes

#
public Graph WithoutNodeAttributes()
Create a new graph without any node attributes.