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:
  1. 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.

  2. If adding costs to an alternate cost type, then the graph must already be compressed

Post Conditions:
  1. If parent or child doesn’t exist in the graph as nodes, they will be added

  2. If cost_type doesn’t already exist in the graph it will be createda

Raises:

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

  1. Once any edges have been added to the graph as an alternate cost type, new edges are no longer able to be created.

  2. 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.