Rename find_path* algorithms to dfs_find_path*
This commit is contained in:
+3
-3
@@ -261,14 +261,14 @@ where
|
||||
(visited, None)
|
||||
}
|
||||
|
||||
pub fn find_path<G>(graph: &G, source: G::Vertex, target: G::Vertex) -> Option<Vec<G::Edge>>
|
||||
pub fn dfs_find_path<G>(graph: &G, source: G::Vertex, target: G::Vertex) -> Option<Vec<G::Edge>>
|
||||
where
|
||||
G: GraphTopology,
|
||||
{
|
||||
find_path_where(graph, source, |v| v == target)
|
||||
dfs_find_path_where(graph, source, |v| v == target)
|
||||
}
|
||||
|
||||
pub fn find_path_where<G, P>(graph: &G, source: G::Vertex, predicate: P) -> Option<Vec<G::Edge>>
|
||||
pub fn dfs_find_path_where<G, P>(graph: &G, source: G::Vertex, predicate: P) -> Option<Vec<G::Edge>>
|
||||
where
|
||||
G: GraphTopology,
|
||||
P: Fn(G::Vertex) -> bool,
|
||||
|
||||
@@ -7,7 +7,7 @@ macro_rules! find_path_tests {
|
||||
let mut graph = <$T>::new();
|
||||
let v = graph.add_vertex();
|
||||
assert_eq!(
|
||||
$crate::algorithms::find_path(&graph, v, v),
|
||||
$crate::algorithms::dfs_find_path(&graph, v, v),
|
||||
Some(vec![]),
|
||||
"path from source to itself should be empty"
|
||||
);
|
||||
@@ -17,7 +17,7 @@ macro_rules! find_path_tests {
|
||||
fn find_path_disconnected() {
|
||||
let (graph, vertices) = make_test_graph_disconnected();
|
||||
assert_eq!(
|
||||
$crate::algorithms::find_path(&graph, vertices[0], vertices[1]),
|
||||
$crate::algorithms::dfs_find_path(&graph, vertices[0], vertices[1]),
|
||||
None,
|
||||
"no path should exist to disconnected vertex"
|
||||
);
|
||||
@@ -30,7 +30,7 @@ macro_rules! find_path_tests {
|
||||
let v1 = graph.add_vertex();
|
||||
let v2 = graph.add_vertex();
|
||||
let e = graph.add_edge(v1, v2);
|
||||
let path = $crate::algorithms::find_path(&graph, v1, v2)
|
||||
let path = $crate::algorithms::dfs_find_path(&graph, v1, v2)
|
||||
.expect("path should exist between adjacent vertices");
|
||||
assert_eq!(
|
||||
path.len(),
|
||||
@@ -43,7 +43,7 @@ macro_rules! find_path_tests {
|
||||
#[test]
|
||||
fn find_path() {
|
||||
let (graph, vertices, _, _) = make_test_graph();
|
||||
let path = $crate::algorithms::find_path(&graph, vertices[0], vertices[9])
|
||||
let path = $crate::algorithms::dfs_find_path(&graph, vertices[0], vertices[9])
|
||||
.expect(&format!(
|
||||
"path should exist between connected vertices {:?} and {:?}",
|
||||
vertices[0], vertices[9]
|
||||
@@ -57,7 +57,7 @@ macro_rules! find_path_tests {
|
||||
let mut graph = <$T>::new();
|
||||
let v = graph.add_vertex();
|
||||
assert_eq!(
|
||||
$crate::algorithms::find_path_where(&graph, v, |u| u == v),
|
||||
$crate::algorithms::dfs_find_path_where(&graph, v, |u| u == v),
|
||||
Some(vec![]),
|
||||
"path from source to itself should be empty"
|
||||
);
|
||||
@@ -67,7 +67,7 @@ macro_rules! find_path_tests {
|
||||
fn find_path_where_disconnected() {
|
||||
let (graph, vertices) = make_test_graph_disconnected();
|
||||
assert_eq!(
|
||||
$crate::algorithms::find_path_where(&graph, vertices[0], |v| v == vertices[1]),
|
||||
$crate::algorithms::dfs_find_path_where(&graph, vertices[0], |v| v == vertices[1]),
|
||||
None,
|
||||
"no path should exist to disconnected vertex"
|
||||
);
|
||||
@@ -77,7 +77,7 @@ macro_rules! find_path_tests {
|
||||
fn find_path_where_no_match() {
|
||||
let (graph, vertices, _, _) = make_test_graph();
|
||||
assert_eq!(
|
||||
$crate::algorithms::find_path_where(&graph, vertices[0], |_| false),
|
||||
$crate::algorithms::dfs_find_path_where(&graph, vertices[0], |_| false),
|
||||
None,
|
||||
"no path should exist when predicate never matches"
|
||||
);
|
||||
@@ -87,7 +87,7 @@ macro_rules! find_path_tests {
|
||||
fn find_path_where() {
|
||||
let (graph, vertices, _, _) = make_test_graph();
|
||||
let path =
|
||||
$crate::algorithms::find_path_where(&graph, vertices[0], |v| v == vertices[9])
|
||||
$crate::algorithms::dfs_find_path_where(&graph, vertices[0], |v| v == vertices[9])
|
||||
.expect(&format!(
|
||||
"path should exist between connected vertices {:?} and {:?}",
|
||||
vertices[0], vertices[9]
|
||||
|
||||
Reference in New Issue
Block a user