Change "neighbor" terminology to "adjacent vertex" throughout the code
This commit is contained in:
+7
-7
@@ -33,8 +33,8 @@ where
|
||||
W: Fn(G::Edge) -> u32,
|
||||
{
|
||||
let mut predecessors = graph.vertex_map(None);
|
||||
let distances = dijkstra_impl(graph, source, weight, |neighbor, predecessor| {
|
||||
predecessors[neighbor] = Some(predecessor);
|
||||
let distances = dijkstra_impl(graph, source, weight, |adjacent, predecessor| {
|
||||
predecessors[adjacent] = Some(predecessor);
|
||||
});
|
||||
DijkstraResult {
|
||||
distances,
|
||||
@@ -92,19 +92,19 @@ where
|
||||
});
|
||||
|
||||
while let Some(v) = heap.pop() {
|
||||
for neighbor in graph.neighbors(v.vertex) {
|
||||
for adjacent in graph.adjacent_vertices(v.vertex) {
|
||||
// TODO: Use custom edge weights in Dijkstra's algorithm.
|
||||
let edge_weight = 1;
|
||||
let new_distance = distances[v.vertex].unwrap() + edge_weight;
|
||||
if match distances[neighbor] {
|
||||
if match distances[adjacent] {
|
||||
None => true,
|
||||
Some(old_distance) if old_distance > new_distance => true,
|
||||
_ => false,
|
||||
} {
|
||||
distances[neighbor] = Some(new_distance);
|
||||
on_relax(neighbor, v.vertex);
|
||||
distances[adjacent] = Some(new_distance);
|
||||
on_relax(adjacent, v.vertex);
|
||||
heap.push(DistanceOrderedVertex {
|
||||
vertex: neighbor,
|
||||
vertex: adjacent,
|
||||
distance: new_distance,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user