routing.pathfinding.core.node#
The node model of the grids: nodes, their attributes, the registry of the grids’ frames (C layout in node.pxd).
- class routing.pathfinding.core.node.AttributeMap#
Bases:
objectThe layout of a node’s attributes and path state, shared by the nodes of a grid.
A node’s lengths are laid out as
[runs..., gaps..., trails...], one of each per toggled attribute: how far the path has held the attribute, how far it has lacked it, and the head of the chain of values it has held (VisitedValues, the search’s own state). The map lays the state a path starts with and advances it along a move: the one definition the search and the replay of a found path follow.- base_attributes#
- custom_attr_size#
- lengths_size#
- class routing.pathfinding.core.node.GridNode#
Bases:
NodeBasic node in a grid.
Attributes#
- xint
The x coordinate of the node.
- yint
The y coordinate of the node.
- zint
The z coordinate of the node.
- walkablebool
Whether this node can be walked through.
- weightfloat
The weight of the node.
- grid_idOptional[int]
The id of the grid this node belongs to.
- connectionsList[GridNode]
The nodes this node is connected to.
- connect(other_node: GridNode) None#
Connect this node to another node.
Parameters#
- other_nodeGridNode
The node to connect to.
- connections#
Returns a Python view of the connections.
- disconnect_all() None#
Remove all connections to and from this node.
- grid_id#
- identifier#
- nbytes#
Calculate precise memory usage in bytes for GridNode attributes.
- position#
Get the world position (center coordinates) of this node’s voxel.
Returns the world coordinates based on the registered grid origin and voxel size.
- Returns:
World coordinates (x, y, z) of the voxel center
- Raises:
ValueError – If the grid_id is None or not registered
- voxel_size#
Get the voxel size for this node’s grid.
- Returns:
Voxel size in world units
- Raises:
ValueError – If the grid_id is None or not registered
- walkable#
- weight#
- x#
- y#
- z#
- class routing.pathfinding.core.node.Node#
Bases:
objectBasic node class, saves calculated values for pathfinding.
Attributes#
- hfloat
The cost from this node to the goal (for A* including the heuristic).
- gfloat
The cost from the start node to this node.
- ffloat
The overall cost for a path using this node (f = g + h).
- openedint
The number of times this node has been opened.
- closedbool
Whether this node is closed.
- parentOptional[Node]
The parent node of this node.
- retain_countint
Used for recursion tracking of IDA*.
- testedbool
Used for IDA* and Jump-Point-Search.
- cleanup() None#
Reset all calculated values, fresh start for pathfinding.
- closed#
- f#
- g#
- h#
- nbytes#
Calculate precise memory usage in bytes for Node attributes.
- opened#
- parent#
- retain_count#
- tested#
- class routing.pathfinding.core.node.SmartGridNode#
Bases:
GridNode- add_forbidden(forbidden_node: SmartGridNode) None#
Add a node to the forbidden list.
- all_neighbors(diagonal: bool = False) list[tuple[int, int, int]]#
- attribute_map#
The layout of the node’s attributes and lengths, shared by the nodes of its grid.
- cheapest_pushed#
- cleanup() None#
Reset all calculated values, fresh start for pathfinding.
- custom_attr#
- derive_path_state(crossed_cells: list | None = None) None#
Set the straight length and the attribute lengths of this node from its parent’s, through the cells the move crosses.
The cells default to this node alone, the move being one step; a segment gives the cells it crosses, this node last. Without a parent, the state a path starts with. The one definition of the search, replayed.
- direction#
- forbidden#
Returns a Python view of the forbidden nodes.
- get_attribute_straight_length(attribute: str) float#
- get_custom_attr(attribute: str)#
- get_direction_from_node(node: SmartGridNode)#
Direction of the step from
nodeto this node, in voxel steps.A step into another grid keeps the heading
nodearrived with: a change of grid is no turn, whatever the offset between the two centres. Without such a heading, the offset between the world centres, quantized and clamped, stands in.
- get_length(attribute: str)#
- get_no_attribute_straight_length(attribute: str) float#
- get_tail(length: float) list[tuple[int, int, int]]#
- get_voxel_distance_to(other: SmartGridNode)#
Euclidean distance normalized by the largest voxel size.
Same grid_id -> trivial same-grid branch.
Different ids -> cross-grid branch (world-center based).
- index#
- lengths#
- nbytes#
Calculate precise memory usage in bytes for SmartGridNode attributes.
- p#
- set_attribute_map(attribute_map: AttributeMap) None#
Set a new attribute map and reallocate arrays.
- set_custom_attr(attribute: str, value)#
- set_length(attribute: str, value)#
- steps_from(node: SmartGridNode) cython.int#
Cells the move from
nodeto this node crosses: one for a step or a change of grid, the segment’s length otherwise.
- straight_length#
- update_direction() None#
- class routing.pathfinding.core.node.VisitedValues#
Bases:
objectThe distinct values of an attribute the paths of one search have held, as chains sharing their suffix.
A state keeps one integer, the head of its chain, so the memory costs one link per change of value along a path and not one set per state. Trail 0 is the empty chain, which every state starts from. For a toggled attribute a chain holds at most the value 1 — the path has held it — and for the pooling labels it holds the corridors the route has been in.
- routing.pathfinding.core.node.clear_all_grids()#
Clear all registered grids - useful for testing isolation.
- routing.pathfinding.core.node.register_grid(grid_id: int, origin: tuple[float, float, float], voxel_size: float)#
Register grid origin and voxel size.
- routing.pathfinding.core.node.unregister_grid(grid_id: int)#
Unregister a grid by removing it from all grid maps.