Module: graph
Contents
StructsGraph- Graph data structure with pathfinding algorithms.
resq_dsa::graph::Graph
Struct Graph data structure with pathfinding algorithms. Provides BFS, Dijkstra’s algorithm, and A* for finding shortest paths in weighted directed graphs.Type Parameters
Id: Node identifier (must be hashable, clonable, comparable)
Use Cases
- Flight path planning
- Network routing
- Game pathfinding
Examples
- Id
fn dijkstra(self: &Self, start: &Id, end: &Id) -> Option<(Vec<Id>, u64)>- Finds the shortest path using Dijkstra’s algorithm.fn astar<H>(self: &Self, start: &Id, end: &Id, h: H) -> Option<(Vec<Id>, u64)>- Finds the shortest path using A* algorithm.fn new() -> Self- Creates a new empty directed graph.fn add_edge(self: & mut Self, from: Id, to: Id, weight: u64)- Adds a directed edge fromfromtotowith the given weight.fn bfs(self: &Self, start: &Id) -> Vec<Id>- Performs breadth-first search starting fromstart.
- Default
fn default() -> Self