Initial release #1

Merged
warrence merged 102 commits from dev into main 2026-06-30 10:26:52 +02:00
Showing only changes of commit 64d0302d64 - Show all commits
+1 -14
View File
@@ -35,14 +35,7 @@ pub fn dijkstra(graph: &Graph, source: Vertex) -> (Vec<Option<u32>>, Vec<Option<
distance: 0,
});
while let Some(v) = heap.pop() {
// TODO: Simplify with a neighbor iterator.
// Finds the first neighbor of v.
let Some(mut incidence) = graph.incidence_headers[v.vertex.0].first_incidence else {
break;
};
loop {
// Processes one neighbor of v.
let neighbor = graph.incidence_vertices[incidence.0];
for neighbor in graph.neighbors(v.vertex) {
// TODO: Add a way to provide custom edge weights for Dijkstra's algorithm.
let edge_weight = 1;
let new_distance = distances[v.vertex.0].unwrap() + edge_weight;
@@ -58,12 +51,6 @@ pub fn dijkstra(graph: &Graph, source: Vertex) -> (Vec<Option<u32>>, Vec<Option<
distance: new_distance,
});
}
// Finds next neighbor of v.
let Some(next) = graph.next_incidences[incidence.0] else {
break;
};
incidence = next;
}
}
(distances, predecessors)