Replace VertexMap and EdgeMap with now public EntityMap
This commit is contained in:
+14
-14
@@ -1,7 +1,7 @@
|
||||
use std::cmp::Ordering;
|
||||
use std::collections::{BinaryHeap, VecDeque};
|
||||
|
||||
use crate::maps::VertexMap;
|
||||
use crate::maps::EntityMap;
|
||||
use crate::traits::{GraphTopology, IncidenceCursor};
|
||||
|
||||
#[derive(PartialEq, Eq)]
|
||||
@@ -23,8 +23,8 @@ impl<V: Eq> Ord for DistanceOrderedVertex<V> {
|
||||
}
|
||||
|
||||
pub struct DijkstraResult<V: Copy> {
|
||||
pub distances: VertexMap<V, Option<u32>>,
|
||||
pub predecessors: VertexMap<V, Option<V>>,
|
||||
pub distances: EntityMap<V, Option<u32>>,
|
||||
pub predecessors: EntityMap<V, Option<V>>,
|
||||
}
|
||||
|
||||
// TODO: Generalize the return type of the weight function.
|
||||
@@ -54,7 +54,7 @@ pub fn dijkstra_distances<G, W>(
|
||||
graph: &G,
|
||||
source: G::Vertex,
|
||||
weight: W,
|
||||
) -> VertexMap<G::Vertex, Option<u32>>
|
||||
) -> EntityMap<G::Vertex, Option<u32>>
|
||||
where
|
||||
G: GraphTopology,
|
||||
W: Fn(G::Edge) -> u32,
|
||||
@@ -65,7 +65,7 @@ where
|
||||
pub fn dijkstra_distances_unweighted<G>(
|
||||
graph: &G,
|
||||
source: G::Vertex,
|
||||
) -> VertexMap<G::Vertex, Option<u32>>
|
||||
) -> EntityMap<G::Vertex, Option<u32>>
|
||||
where
|
||||
G: GraphTopology,
|
||||
{
|
||||
@@ -77,7 +77,7 @@ fn dijkstra_impl<G, W, F>(
|
||||
source: G::Vertex,
|
||||
weight: W,
|
||||
mut on_relax: F,
|
||||
) -> VertexMap<G::Vertex, Option<u32>>
|
||||
) -> EntityMap<G::Vertex, Option<u32>>
|
||||
where
|
||||
G: GraphTopology,
|
||||
W: Fn(G::Edge) -> u32,
|
||||
@@ -113,8 +113,8 @@ where
|
||||
}
|
||||
|
||||
pub struct BfsResult<V: Copy> {
|
||||
pub distances: VertexMap<V, Option<u32>>,
|
||||
pub predecessors: VertexMap<V, Option<V>>,
|
||||
pub distances: EntityMap<V, Option<u32>>,
|
||||
pub predecessors: EntityMap<V, Option<V>>,
|
||||
}
|
||||
|
||||
pub fn bfs<G>(graph: &G, source: G::Vertex) -> BfsResult<G::Vertex>
|
||||
@@ -132,7 +132,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
pub fn bfs_distances<G>(graph: &G, source: G::Vertex) -> VertexMap<G::Vertex, Option<u32>>
|
||||
pub fn bfs_distances<G>(graph: &G, source: G::Vertex) -> EntityMap<G::Vertex, Option<u32>>
|
||||
where
|
||||
G: GraphTopology,
|
||||
{
|
||||
@@ -158,7 +158,7 @@ where
|
||||
}
|
||||
|
||||
struct BfsImplResult<V: Copy> {
|
||||
distances: VertexMap<V, Option<u32>>,
|
||||
distances: EntityMap<V, Option<u32>>,
|
||||
found: Option<(V, u32)>,
|
||||
}
|
||||
|
||||
@@ -195,8 +195,8 @@ where
|
||||
}
|
||||
|
||||
pub struct DfsResult<V: Copy> {
|
||||
pub visited: VertexMap<V, bool>,
|
||||
pub predecessors: VertexMap<V, Option<V>>,
|
||||
pub visited: EntityMap<V, bool>,
|
||||
pub predecessors: EntityMap<V, Option<V>>,
|
||||
}
|
||||
|
||||
pub fn dfs<G>(graph: &G, source: G::Vertex) -> DfsResult<G::Vertex>
|
||||
@@ -214,7 +214,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
pub fn dfs_visited<G>(graph: &G, source: G::Vertex) -> VertexMap<G::Vertex, bool>
|
||||
pub fn dfs_visited<G>(graph: &G, source: G::Vertex) -> EntityMap<G::Vertex, bool>
|
||||
where
|
||||
G: GraphTopology,
|
||||
{
|
||||
@@ -240,7 +240,7 @@ where
|
||||
}
|
||||
|
||||
struct DfsImplResult<V: Copy> {
|
||||
visited: VertexMap<V, bool>,
|
||||
visited: EntityMap<V, bool>,
|
||||
found: Option<V>,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user