From 6a0c426c77ed36a16b31e2df06336215a1bdd8f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20M=C3=BCller?= Date: Fri, 3 Jul 2026 21:43:55 +0200 Subject: [PATCH] Rename find_path* algorithms to dfs_find_path* --- src/algorithms.rs | 6 +++--- src/testing/find_path_testing.rs | 16 ++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/algorithms.rs b/src/algorithms.rs index a2620b8..730ed4c 100644 --- a/src/algorithms.rs +++ b/src/algorithms.rs @@ -261,14 +261,14 @@ where (visited, None) } -pub fn find_path(graph: &G, source: G::Vertex, target: G::Vertex) -> Option> +pub fn dfs_find_path(graph: &G, source: G::Vertex, target: G::Vertex) -> Option> 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(graph: &G, source: G::Vertex, predicate: P) -> Option> +pub fn dfs_find_path_where(graph: &G, source: G::Vertex, predicate: P) -> Option> where G: GraphTopology, P: Fn(G::Vertex) -> bool, diff --git a/src/testing/find_path_testing.rs b/src/testing/find_path_testing.rs index c7cfbdc..ead7839 100644 --- a/src/testing/find_path_testing.rs +++ b/src/testing/find_path_testing.rs @@ -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]