Skip to content

Commit 15a296a

Browse files
jberg5IvanIsCoding
andauthored
Fix find_successor_node_by_edge (#1551)
* Fix bug * Add the release note --------- Co-authored-by: Ivan Carvalho <8753214+IvanIsCoding@users.noreply.github.com> Co-authored-by: Ivan Carvalho <ivancarvalho@gatech.edu>
1 parent 64e5936 commit 15a296a

3 files changed

Lines changed: 8 additions & 2 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
fixes:
3+
- |
4+
Fixed a bug in `~rustworkx.PyDiGraph.find_successor_node_by_edge` where
5+
the method always returned the source node by mistake. Now, it returns
6+
any of the successors, as originally intended.

src/digraph.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2359,7 +2359,7 @@ impl PyDiGraph {
23592359
let edge_predicate_raw = predicate_callable(edge.weight())?;
23602360
let edge_predicate: bool = edge_predicate_raw.extract(py)?;
23612361
if edge_predicate {
2362-
return Ok(self.graph.node_weight(edge.source()).unwrap());
2362+
return Ok(self.graph.node_weight(edge.target()).unwrap());
23632363
}
23642364
}
23652365
Err(NoSuitableNeighbors::new_err("No suitable neighbor"))

tests/digraph/test_edges.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ def compare_edges(edge):
288288
return "b to c" == edge
289289

290290
res = dag.find_successor_node_by_edge(node_b, compare_edges)
291-
self.assertEqual("b", res)
291+
self.assertEqual("c", res)
292292

293293
def test_find_successor_node_by_edge_no_match(self):
294294
dag = rustworkx.PyDiGraph()

0 commit comments

Comments
 (0)