Graph
References[IoId("00000000-829a-4b06-a994-bd151aeb0e37")]
public sealed class Graph : IStorable, IEquatable<Graph>, IComparable<Graph>
Represents an immutable graph.
Constructors
Properties
Methods
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.
Parameters:
| nodes (IEnumerable<(Point3d location, MetaData attributes)>) | |
| edges (IEnumerable<(int a, int b, MetaData attributes)>) |
Create
#Create a graph from nodes and edges without any attributes.
Parameters:
| nodes (IEnumerable<Point3d>) | |
| edges (IEnumerable<(int a, int b)>) |
CreateComplete
#Create a graph by connecting all nodes with all other nodes.
Parameters:
| 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
#Create a graph based on a 2D convex hull.
Parameters:
| 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
#Create a graph based on a 3D convex hull.
Parameters:
| 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. |
CreateFromSpanningTree
#Create a spanning tree graph from a set of points. Note that spanning trees are usually not unique.
CreateFromTesselation
#Create a graph from a delaunay triangulation.
DumpToRhino
#public void DumpToRhino()
FindCheapestCosts
#Find the cost of the cheapest route from one node to every other node.
Parameters:
| 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. |
Returns: The cost per node, positive infinity for nodes which cannot be reached.
FindCheapestRoute
#Find the cheapest route between two nodes.
Parameters:
| 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. |
Returns: The cheapest route, or null if the end cannot be reached.
FindMinimumSpanningTree
#A not very performant implementation of a minimum-spanning-tree finder.
Parameters:
| points (Point3d[]) | Points to connect. |
| initialEdges ((int, int)[] = null) | Optional initial edge setup. |
Returns: Collection of edges describing the minimum spanning tree.
FindMinimumSpanningTree
#A not very performant implementation of a minimum-spanning-tree finder.
Parameters:
| points (Point3d[]) | Points to connect. |
Returns: 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.
Parameters:
| maxNodes (int = 2147483647) | |
| maxEdges (int = 2147483647) | |
| includeAttributes (bool = false) | |
| format (NumberFormat = null) |
Merge
#Merge a set of graphs into a single one.
Parameters:
| graphs (params Graph[]) | Graphs to merge. |
Returns: Merged graph.
RemoveNodes
#Create a new graph without the indicated nodes. This may also affect the edges, as edges may not be left dangling.
Parameters:
| delete (bool[]) |
RemoveNodes
#Create a new graph without the indicated nodes. This may also affect the edges, as edges may not be left dangling.
Parameters:
| nodeIndices (int[]) |