Documentation Index
Fetch the complete documentation index at: https://mintlify.com/tutosrive/Constellations/llms.txt
Use this file to discover all available pages before exploring further.
dijkstra_simple implements Dijkstra’s algorithm on a Graph instance. It is a module-level function located in src/controllers/Dijkstra.py and is called by both GraphController.get_shortest_path() and GraphController.get_shortest_path_avoiding(). The function operates on a standard adjacency-list graph, processes vertices in order of their tentative distance, and stops as soon as the target vertex is dequeued — making it efficient for point-to-point queries on the sparse constellation graphs used in this project.
Signature
Parameters
A loaded
Graph instance. The function calls graph.get_vertices() to enumerate all vertex labels and graph.get_vertex(u).get_connections() to iterate over a vertex’s neighbours and their edge metadata.The label of the starting vertex. Its initial distance is set to
0; all others are initialised to math.inf.The label of the destination vertex. The main loop breaks early once
target_id is selected as the minimum-distance unvisited vertex.Return Value
Maps every vertex label to its shortest known distance from
start_id. Unreachable vertices retain the value math.inf.Maps every vertex label to its predecessor on the shortest path. The start vertex maps to
None. Used to reconstruct the path by walking backwards from target_id.Ordered list of vertex labels from
start_id to target_id, reconstructed by following pred from target_id back to start_id and then reversing. If target_id is unreachable, the list will still contain target_id but the chain will not extend all the way back to start_id.Blocked Edge Handling
During neighbour relaxation, the function checks each edge’s metadata dict for the"blocked" flag before applying any distance update:
"blocked" is absent from the edge data it defaults to False, so all freshly created edges are traversable. Edges can be toggled at runtime via GraphController.toggle_edge().
Unreachable Targets
Iftarget_id cannot be reached from start_id (because all connecting edges are blocked, or no path exists), the main loop exits when the minimum remaining distance becomes math.inf:
dist[target_id] remains math.inf. The path-reconstruction loop still runs, but because pred[target_id] is None, it produces [target_id] — a one-element list containing only the unreachable destination. Callers should check dist[target_id] == math.inf or len(path) <= 1 to detect this condition.