Skip to content

Commit

Permalink
Added small fix to stop edges returning self loops twice (#1485)
Browse files Browse the repository at this point in the history
* added filter

* fixed tests
  • Loading branch information
miratepuffin authored Feb 14, 2024
1 parent 1fcd3fb commit 4e65269
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion python/tests/test_graphdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def test_windowed_graph_edges():
for e in e_iter:
edges.append([e.src.id, e.dst.id])

assert edges == [[1, 1], [1, 1], [1, 2], [1, 3], [1, 2], [3, 2], [1, 3], [3, 2]]
assert edges == [[1, 1], [1, 2], [1, 3], [1, 2], [3, 2], [1, 3], [3, 2]]

tedges = [v.in_edges for v in view.nodes]
in_edges = []
Expand Down
2 changes: 1 addition & 1 deletion raphtory/src/db/graph/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ mod db_tests {
g.add_edge(*t, *src, *dst, NO_PROPS, None).unwrap();
}

let expected = vec![(2, 3, 2), (1, 0, 0), (1, 0, 0)];
let expected = vec![(2, 3, 1), (1, 0, 0), (1, 0, 0)];
let actual = (1..=3)
.map(|i| {
let v = g.node(i).unwrap();
Expand Down
1 change: 1 addition & 0 deletions raphtory/src/db/internal/graph_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ impl<'graph, const N: usize> GraphOps<'graph> for InnerTemporalGraph<N> {
}
Direction::BOTH => Box::new(
self.node_edges(v, Direction::IN, layers.clone(), filter)
.filter(|e| e.src() != e.dst())
.merge(self.node_edges(v, Direction::OUT, layers, filter)),
),
}
Expand Down

0 comments on commit 4e65269

Please sign in to comment.