DHART
|
A graph representing connections between points in space. More...
Public Member Functions | |
Graph () | |
Construct a new empty graph in unmanaged memory. | |
void | AddEdge (Vector3D parent, Vector3D child, float cost, string cost_type="") |
Create a new edge between parent and child with cost. More... | |
void | AddEdge (int parent_id, int child_id, float cost, string cost_type="") |
Create a new edge between parent and child with cost. More... | |
NodeList | getNodes () |
Get an array containing the graph's current nodes. More... | |
CSRInfo | CompressToCSR (string cost_type="") |
Compress the graph into a CSR representation, and get pointers to it. More... | |
ManagedFloatArray | AggregateEdgeCosts (GraphEdgeAggregation type, bool directed=true, string cost_type="") |
Summarize the edgecosts of every node in the graph. More... | |
float | GetCost (int parent, int child, string cost_type="") |
Get the cost of traversing between parent and child More... | |
int | GetNodeID (Vector3D node) |
Gets the ID of a node in the graph. More... | |
void | AddNodeAttribute (int id, string attribute, string score) |
Define a node attribute for the node at id. More... | |
void | AddNodeAttribute (string attribute, int[] ids, string[] scores) |
Add attribute to all node in ids, with their respective score in scores. More... | |
void | AddNodeAttribute< T > (string attribute, IEnumerable< T > scores) |
Add attribute to all node in ids, with their respective score in scores. More... | |
string[] | GetNodeAttributes (string attribute) |
Get the score of every node for a given attribute. More... | |
void | ClearNodeAttributes (string attribute) |
Clear an attribute and all of its scores from the graph. More... | |
int | NumNodes () |
Get the number of nodes in this graph. More... | |
void | AttrsToCosts (string attribute_key, string cost_key, Direction dir) |
Generate a cost set based on a set of node parameters. More... | |
Public Member Functions inherited from DHARTAPI.NativeUtils.NativeObject | |
void | UpdatePressure (int new_pressure) |
Update the pressure of this object. | |
Protected Member Functions | |
override bool | ReleaseHandle () |
Free the native memory managed by this class. More... | |
Additional Inherited Members | |
Public Attributes inherited from DHARTAPI.NativeUtils.NativeObject | |
int | pressure |
the size of the object pointed to in unmanaged memory in bytes. Used to exert pressure on the GC. More... | |
Properties inherited from DHARTAPI.NativeUtils.NativeObject | |
override bool | IsInvalid [get] |
There is no way to invalidate this class without destroying it, so will always return false. | |
A graph representing connections between points in space.
Every Node in the graph contains an X,Y,Z coordinate which can be used to represent a specific point in space. This graph internally is stored as a Sparse Matrix for space efficency. Nodes are stored in a hashmap containing X,Y, and Z coordinates, allowing for quick indexing of specific nodes by location alone. Access to this graph's internal CSR is available through Graph.CompressToCSR().
Distance
which can be accessed explicitly by the key "Distance" or leaving the cost_type field blank. Alternate costs have corresponding edges in the default cost set, but different costs to traverse from the parent to the child node.void DHARTAPI.SpatialStructures.Graph.AddEdge | ( | int | parent_id, |
int | child_id, | ||
float | cost, | ||
string | cost_type = "" |
||
) |
Create a new edge between parent and child with cost.
parent_id | The ID of the parent node. |
child_id | The ID of the child node. |
cost | cost from parent to child. |
cost_type | The type of cost to add this edge to. If left blank will add the edge to the graph's default cost type. |
parent
and child
already exist in the graph.cost_type
is not blank, and does not refer to the default cost type or any other cost that already exists in the graph, a new cost type will be created.LogicError | tried to add an alternate cost to the graph before it was compressed |
InvalidCostOperation | Tried to add an alternate cost that doesn't exist in the graph's default cost type. |
39
void DHARTAPI.SpatialStructures.Graph.AddEdge | ( | Vector3D | parent, |
Vector3D | child, | ||
float | cost, | ||
string | cost_type = "" |
||
) |
Create a new edge between parent and child with cost.
parent | The X,Y,Z location for the parent node. |
child | x,y,z location for the child |
cost | cost for parent to child |
cost_type | The type of cost to add the edge to. |
parent
and child
already exist in the graph.cost_type
is not blank, and does not refer to the default cost type or any other cost that already exists in the graph, a new cost type will be created.LogicError | tried to add an alternate cost to the graph before it was compressed |
InvalidCostOperation | Tried to add an alternate cost that doesn't exist in the graph's default cost type. |
39
void DHARTAPI.SpatialStructures.Graph.AddNodeAttribute | ( | int | id, |
string | attribute, | ||
string | score | ||
) |
Define a node attribute for the node at id.
id | The ID of the node that will receive attribute. |
attribute | The name of the attribute to use. |
score | The score for attribute to store for this node. |
>>> 0
>>> 100
>>> 200
References DHARTAPI.SpatialStructures.Graph.AddNodeAttribute().
Referenced by DHARTAPI.SpatialStructures.Graph.AddNodeAttribute(), and DHARTAPI.SpatialStructures.Graph.AddNodeAttribute< T >().
void DHARTAPI.SpatialStructures.Graph.AddNodeAttribute | ( | string | attribute, |
int[] | ids, | ||
string[] | scores | ||
) |
Add attribute to all node in ids, with their respective score in scores.
ids | IDs of nodes to assign scores to for attribute |
attribute | Name of the attribute to assigns cores to for each node in ids |
scores | Ordered ids of scores to add to the node at the id in ids at the same index |
ids
and scores
must match>>> 0
>>> 100
>>> 200
void DHARTAPI.SpatialStructures.Graph.AddNodeAttribute< T > | ( | string | attribute, |
IEnumerable< T > | scores | ||
) |
Add attribute to all node in ids, with their respective score in scores.
attribute | Name of the attribute to assign scores to for each node in the graph |
scores | Ordered ids of scores to add to the node at the id in ids at the same index |
ArgumentException | The number of scores in scores isn't equal to the nubmer of nodes in the graph |
T | : | IFormattable |
References DHARTAPI.SpatialStructures.Graph.AddNodeAttribute(), and DHARTAPI.SpatialStructures.Graph.NumNodes().
ManagedFloatArray DHARTAPI.SpatialStructures.Graph.AggregateEdgeCosts | ( | GraphEdgeAggregation | type, |
bool | directed = true , |
||
string | cost_type = "" |
||
) |
Summarize the edgecosts of every node in the graph.
type | The type of aggregation method to use. |
directed | Whether or not the graph is directed. If set to true then each nodes's score will only consider incomning edges. Otherwise, each node's score will consider both outgoing and incoming edges. |
cost_type | The type of cost to use for aggregating the edges. |
KeyNotFoundException | Cost specified didn't match the default cost, or any other cost type defined in the graph. |
[150, 20, 0]
References DHARTAPI.SpatialStructures.Graph.CompressToCSR(), and DHARTAPI.SpatialStructures.Graph.NumNodes().
void DHARTAPI.SpatialStructures.Graph.AttrsToCosts | ( | string | attribute_key, |
string | cost_key, | ||
Direction | dir | ||
) |
Generate a cost set based on a set of node parameters.
attribute_key | Attribute to create a new cost set from. |
cost_key | Key for the newly generated cost set. |
dir | Direction to use for calculating the cost of any edge. For example INCOMING will use the cost of the node being traveled to by the edge. |
KeyNotFoundException | The parameter assinged by parameter_name is not the key of any node parameter in the graph. |
attribute_key
already exists in the graph cost_key
.0->1 = 100, 0->2 = 200
void DHARTAPI.SpatialStructures.Graph.ClearNodeAttributes | ( | string | attribute | ) |
Clear an attribute and all of its scores from the graph.
attribute | The unique key of the attribute to clear from the graph. |
>>> 0
CSRInfo DHARTAPI.SpatialStructures.Graph.CompressToCSR | ( | string | cost_type = "" | ) |
Compress the graph into a CSR representation, and get pointers to it.
cost_type | Change the type of cost that's carried in the CSR's values array. If left blank, will use the graph's default cost type. |
KeyNotFoundException | cost_type is not blank, the name of the graph's default cost type, or the name of any already defined cost type in the graph. |
(nnz: 1, rows: 3, cols: 3)
Referenced by DHARTAPI.SpatialStructures.Graph.AggregateEdgeCosts(), and StringToEdgeCost.Main().
float DHARTAPI.SpatialStructures.Graph.GetCost | ( | int | parent, |
int | child, | ||
string | cost_type = "" |
||
) |
Get the cost of traversing between parent
and child
parent | Node that's being traversed from |
child | Node that's being traversed to |
cost_type | The cost type to retrieve. If blank, the graph's default cost will be used. |
parent
to child
.LogicError | The graph wasn't compressed before calling this function. |
KeyNotFoundExeption | The cost_type specified was not the default cost, blank, or the name of any cost that currently belongs to the graph. |
100
string[] DHARTAPI.SpatialStructures.Graph.GetNodeAttributes | ( | string | attribute | ) |
Get the score of every node for a given attribute.
attribute | The unique name of the attribute type to get from the graph fopr every node |
attribute
, type was found in the graph, then an array of scores for each node is returned in order of ID. For example, the score of the node with id 10 would be stored at index 10, id 12 stored at index 12, etc. Nodes without scores for attribute
will have empty strings at their indexes.attribute
didn't exist in the graph, then an empty array of strings will be returned.0, 100, 200,
0, 100, 200, ,
int DHARTAPI.SpatialStructures.Graph.GetNodeID | ( | Vector3D | node | ) |
Gets the ID of a node in the graph.
node | The X,Y,Z position of a node to get the ID for. |
0
1
-1
Referenced by DHARTAPI.Pathfinding.ShortestPath.DijkstraShortestPath().
NodeList DHARTAPI.SpatialStructures.Graph.getNodes | ( | ) |
Get an array containing the graph's current nodes.
[(0, 0, 2), (0, 0, 1)]
int DHARTAPI.SpatialStructures.Graph.NumNodes | ( | ) |
Get the number of nodes in this graph.
3
Referenced by DHARTAPI.SpatialStructures.Graph.AddNodeAttribute< T >(), DHARTAPI.SpatialStructures.Graph.AggregateEdgeCosts(), DHARTAPI.Pathfinding.ShortestPath.DijkstraAllToAll(), and DHARTAPI.Pathfinding.ShortestPath.GeneratePredecessorAndDistanceMatricies().
|
protected |
Free the native memory managed by this class.