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.
Graph and Vertex are the core data model powering all controllers and algorithms in Constellations. Together they implement a weighted, undirected graph using an adjacency-dictionary approach: each Vertex holds a dict mapping neighbour labels to edge weights, and Graph acts as the top-level registry that creates vertices and wires them together. Every traversal, pathfinding, and simulation feature in the project operates on an instance of Graph.
Vertex
Vertex represents a single node in the graph — typically a star in the constellation map. It stores the node’s identifier, an optional properties dict, and its adjacency mapping.
Constructor
The unique label for this vertex (e.g. a star name or integer index). Used as the key in
Graph.vertex_list and in every adjacency dict of neighbouring vertices.An optional dictionary of arbitrary properties attached to this vertex. In the Constellations project this is typically a star-properties dict (e.g.
{"name": "Sirius", "hypergiant": False}). Defaults to an empty dict {} when not supplied.| Attribute | Type | Description |
|---|---|---|
id | any | The vertex label passed at construction. |
data | dict | Star-properties dict (empty {} if none provided). |
adjacent | dict | Maps neighbour id → edge weight. Starts empty. |
Methods
add_neighbor(neighbor, weight=0)
Registers neighbor as an adjacent node with the given weight.
The
id of the neighbouring vertex.The edge weight to store. In this project, weights are dicts (see note below), but the method accepts any value.
None
get_connections() → dict
Returns the full adjacency dictionary: {neighbour_id: weight, ...}.
Returns: dict
get_id() → any
Returns the vertex’s identifier (self.id).
Returns: any
Full class source
Graph
Graph is the top-level container. It holds a dict of all Vertex objects and exposes helpers to add vertices, create edges, and look up nodes by label.
Constructor
| Attribute | Type | Description |
|---|---|---|
vertex_list | dict | Maps vertex id → Vertex instance. |
num_vertex | int | Running count of vertices added (starts at 0). |
Methods
add_vertex(id, data=None) → Vertex
Adds a new vertex for id if it does not already exist, incrementing num_vertex. If the vertex already exists and data is provided, its data attribute is updated in place. Always returns the Vertex object.
Label for the vertex to add or update.
Property dict to attach to the vertex. Ignored when the vertex already exists and
data is None.Vertex
add_edge(from_id, to_id, weight=0)
Creates an undirected edge between from_id and to_id with the given weight. If either vertex does not exist it is created automatically via add_vertex. Calls add_neighbor on both sides to maintain the undirected invariant.
Label of the source vertex.
Label of the destination vertex.
Value stored on both half-edges. Typically a dict in this project (see note below).
None
get_vertex(id) → Vertex | None
Looks up a vertex by its label. Returns None when id is not present.
The label of the vertex to retrieve.
Vertex | None
get_vertices() → KeysView
Returns a live view of all vertex labels currently stored in vertex_list.
Returns: KeysView (equivalent to dict.keys())
Full class source
Edge weights in Constellations are dicts, not plain numbers. A typical weight passed to
add_edge looks like {"distance": 5, "blocked": False}. The weight parameter on both add_edge and add_neighbor accepts any value, so this convention is purely by project agreement rather than enforced by the class.