DHART
Loading...
Searching...
No Matches
DHARTAPI.SpatialStructures.CostAlgorithms Class Reference

Several cost algorithms that generate alternate costs for edges in a Graph. More...

Static Public Member Functions

static void CalculateAndStoreCrossSlope (Graph g)
 Calculate the cross slope for every edge in a graph and store it as a new cost type within the graph. More...
 
static void CalculateAndStoreEnergyExpenditure (Graph g)
 Calculate the energy expenditure for every edge in a graph and store it as a new cost type within the graph. More...
 

Detailed Description

Several cost algorithms that generate alternate costs for edges in a Graph.

All algorithms in this class behave in a similar manner. They all accept a graph, perform some calculation then store their results as an alternate set of costs in the graph. The names used as keys to access each specific cost in the graph are available in the static CostAlgorithmNames class.

See also
Graph for more information about how alternate costs can be used.

Member Function Documentation

◆ CalculateAndStoreCrossSlope()

static void DHARTAPI.SpatialStructures.CostAlgorithms.CalculateAndStoreCrossSlope ( Graph  g)
static

Calculate the cross slope for every edge in a graph and store it as a new cost type within the graph.

Parameters
gThe graph of nodes and edges to calculate this score for.
Postcondition
The results of the cross slope between every edge in g is stored within g as an alternate cost accessible with CostAlgorithmNames.CrossSlope.
// Create the graph
Graph g = new Graph();
// Create 7 nodes
Vector3D n0 = new Vector3D(2, 6, 6);
Vector3D n1 = new Vector3D(0, 0, 0);
Vector3D n2 = new Vector3D(-5, 5, 4);
Vector3D n3 = new Vector3D(-1, 1, 1);
Vector3D n4 = new Vector3D(2, 2, 2);
Vector3D n5 = new Vector3D(5, 3, 2);
Vector3D n6 = new Vector3D(-2, -5, 1);
// Add 9 edges
g.AddEdge(n0, n1, 0); // [ -2, -6, -6 ]
g.AddEdge(n1, n2, 0); // [ -5, 5, 4 ]
g.AddEdge(n1, n3, 0); // [ -1, 1, 1 ]
g.AddEdge(n1, n4, 0); // [ 2, 2, 2 ]
g.AddEdge(n2, n4, 0); // [ -9, -3, -2 ]
g.AddEdge(n3, n5, 0); // [ -6, 2, 1 ]
g.AddEdge(n5, n6, 0); // [ -7, -8, -1 ]
g.AddEdge(n4, n6, 0); // [ -6, -7, -1 ]
// Compress the graph after adding edges
// Calculate and store edge type in g: cross slope
Several cost algorithms that generate alternate costs for edges in a Graph.
Definition: Graph.cs:587
static void CalculateAndStoreCrossSlope(Graph g)
Calculate the cross slope for every edge in a graph and store it as a new cost type within the graph.
A graph representing connections between points in space.
Definition: Graph.cs:112
CSRInfo CompressToCSR(string cost_type="")
Compress the graph into a CSR representation, and get pointers to it.
Definition: Graph.cs:241
void AddEdge(Vector3D parent, Vector3D child, float cost, string cost_type="")
Create a new edge between parent and child with cost.
A three dimensional vector with built in utility functions.
Definition: CommonTypes.cs:40

◆ CalculateAndStoreEnergyExpenditure()

static void DHARTAPI.SpatialStructures.CostAlgorithms.CalculateAndStoreEnergyExpenditure ( Graph  g)
static

Calculate the energy expenditure for every edge in a graph and store it as a new cost type within the graph.

Parameters
gThe graph of nodes and edges to calculate this score for.
Postcondition
The results of the cross slope between every edge in g is stored within g as an alternate cost accessible with CostAlgorithmNames.EnergyExpenditure
// Requires #include "graph.h"
// Create 7 nodes
Node n0(0, 0, 0);
Node n1(0, 0, 1);
Node n2(5, 5, 4);
Node n3(2, 2, 2);
Node n4(5, 3, 2);
Node n5(6, 6, 7);
Node n6(2, 5, 1);
// Adding 8 edges
g.addEdge(n0, n1);
g.addEdge(n1, n2);
g.addEdge(n1, n3);
g.addEdge(n1, n4);
g.addEdge(n3, n5);
g.addEdge(n4, n2);
g.addEdge(n6, n4);
g.addEdge(n6, n5);
// Always compress the graph after adding edges!
g.Compress();
// Calculate and store edge type in g: energy expenditure
static void CalculateAndStoreEnergyExpenditure(Graph g)
Calculate the energy expenditure for every edge in a graph and store it as a new cost type within the...
A point in space.
Definition: Node.cs:17

The documentation for this class was generated from the following file: