Skip to content

Commit

Permalink
fix issue with edge repr multiple layer
Browse files Browse the repository at this point in the history
  • Loading branch information
shivamka1 committed Nov 25, 2024
1 parent 0414b7f commit 60afe1d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
10 changes: 10 additions & 0 deletions python/tests/test_graphdb/test_graphdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -3047,6 +3047,16 @@ def test_create_node_graph_with_deletion():
assert "Node already exists" in str(excinfo.value)


def test_edge_layer_properties():
g = Graph()
g.add_edge(1, "A", "B", properties={"greeting": "howdy"}, layer="layer 1")
g.add_edge(2, "A", "B", properties={"greeting": "hello"}, layer="layer 2")
g.add_edge(3, "A", "B", properties={"greeting": "ola"}, layer="layer 2")
g.add_edge(3, "A", "B", properties={"greeting": "namaste"}, layer="layer 3")

assert g.edge("A", "B").properties == {"greeting": "namaste"}


@fixture
def datadir(tmpdir, request):
filename = request.module.__file__
Expand Down
5 changes: 4 additions & 1 deletion raphtory/src/core/storage/raw_edges.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use std::{
Arc,
},
};
use itertools::Itertools;

#[derive(Debug, Serialize, Deserialize, PartialEq)]
pub struct EdgeShard {
Expand Down Expand Up @@ -292,7 +293,9 @@ impl<'a> EdgeRGuard<'a> {
Box::new(
self.guard
.props_iter(self.offset)
.flat_map(|(_, layer)| layer.temporal_prop_ids()),
.map(|(_, layer)| layer.temporal_prop_ids())
.kmerge()
.dedup(),
)
}
}
Expand Down
13 changes: 13 additions & 0 deletions raphtory/src/db/api/view/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -780,4 +780,17 @@ mod test_materialize {
g.add_edge(0, 1, 2, props_0.clone(), None).unwrap();
assert!(g.add_edge(1, 1, 2, props_1.clone(), None).is_err());
}

#[test]
fn test_my_graph() {
let g = Graph::new();
g.add_edge(1, "A", "B", [("greeting", "howdy")], Some("layer 1")).unwrap();
g.add_edge(2, "A", "B", [("greeting", "ola")], Some("layer 2")).unwrap();
g.add_edge(2, "A", "B", [("greeting", "hello")], Some("layer 2")).unwrap();
g.add_edge(3, "A", "B", [("greeting", "namaste")], Some("layer 3")).unwrap();

let edge_ab = g.edge("A", "B").unwrap();
let props = edge_ab.properties().iter().map(|(k, v)| (k.to_string(), v.to_string())).collect::<Vec<_>>();
assert_eq!(props, vec![("greeting".to_string(), "namaste".to_string())]);
}
}

0 comments on commit 60afe1d

Please sign in to comment.