dhart.spatialstructures.Graph.AddEdgeToGraph¶
- Graph.AddEdgeToGraph(parent: Tuple[float, float, float] | NodeStruct | int, child: Tuple[float, float, float] | NodeStruct | int, cost: float, cost_type: str = '') None ¶
Add a new edge to the graph from parent to child with the given cost
- Parameters:
parent – Either a node with values for x,y, and z, or an integer representing a node ID
child – Where the edge from parent is going to. Must be the same type of parent i.e. if parent is an int, then the child must also be an int
cost – the cost from parent to child
cost_type – The type of cost to add this edge to. If left blank or as the empty string then the edge will be added to the graph’s default cost set.
- Pre Conditions:
If cost_type is not left blank, then the edge from parent to child must already exist in the graph for its default cost type.
If adding costs to an alternate cost type, then the graph must already be compressed
- Post Conditions:
If parent or child doesn’t exist in the graph as nodes, they will be added
If cost_type doesn’t already exist in the graph it will be createda
- Raises:
dhart.Exceptions.LogicError – Tried to add an alternate cost type to an uncompressed graph
dhart.Exceptions.InvalidCostOperation – Tried to add an alternate cost tot he graph with an edge that didn’t first exist in the graph’s default cost set
Note
The graph offers some basic functionality to add edges and nodes but it’s main use is to provide access to the output of the GraphGenerator and VisibilityGraph. If adding edges or alternate cost types please make sure to read the documentation for these functions and that all preconditions are followed.
Warning
Once any edges have been added to the graph as an alternate cost type, new edges are no longer able to be created.
While this function can be called with integers for both paren and child id, doing so is not recommended unless you are sure that both ids already exist in the graph. If an ID is added that does not already exist in the graph, it will cause certain functions to behave incorrectly. This was mostly implemented for the sake of testing.