Skip to content

AddEdgeToGraph Python Implementation #90

@coliem

Description

@coliem

def AddEdgeToGraph(
self,
parent: Union[Tuple[float, float, float], NodeStruct, int],
child: Union[Tuple[float, float, float], NodeStruct, int],
cost: float,
cost_type: str = ""
) -> None:

It's possible to pass in NodeStruct data structures as parent and child, yet there is no support for this in the native functions. The pipeline goes from the else statement in

if isinstance(parent, int) and isinstance(child, int):
spatial_structures_native_functions.C_AddEdgeFromNodeIDs(
self.graph_ptr, parent, child, cost, cost_type
)
else:
spatial_structures_native_functions.C_AddEdgeFromNodes(
self.graph_ptr, parent, child, cost, cost_type
)

to

def C_AddEdgeFromNodes(
graph_ptr: c_void_p,
parent: Tuple[float, float, float],
child: Tuple[float, float, float],
score: float,
cost_type: str,
) -> None:

where the only allowed data type for the parent and child is Tuple[float,float,float]. This results in an error when calling

parent_ptr = ConvertPointsToArray(parent)
child_ptr = ConvertPointsToArray(child)

which relies on the parent and child being passed in by their xyz coordinates.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions