Skip to content

Commit

Permalink
add tests and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
shivam-880 committed Nov 25, 2024
1 parent 60afe1d commit 1584b5e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion raphtory/src/core/storage/raw_edges.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use crate::{
},
db::api::storage::graph::edges::edge_storage_ops::{EdgeStorageOps, MemEdge},
};
use itertools::Itertools;
use lock_api::ArcRwLockReadGuard;
use parking_lot::{RwLock, RwLockReadGuard, RwLockWriteGuard};
use raphtory_api::core::{entities::EID, storage::timeindex::TimeIndexEntry};
Expand All @@ -18,7 +19,6 @@ use std::{
Arc,
},
};
use itertools::Itertools;

#[derive(Debug, Serialize, Deserialize, PartialEq)]
pub struct EdgeShard {
Expand Down
20 changes: 14 additions & 6 deletions raphtory/src/db/api/view/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -782,15 +782,23 @@ mod test_materialize {
}

#[test]
fn test_my_graph() {
fn test_edge_layer_properties() {
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();
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<_>>();
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())]);
}
}
3 changes: 2 additions & 1 deletion raphtory/src/python/types/macros/trait_impl/edgeviewops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@ macro_rules! impl_edgeviewops {
self.$field.nbr()
}

/// Explodes an edge and returns all instances it had been updated as seperate edges
/// Explodes returns an edge object for each update within the original edge.
fn explode(
&self,
) -> <$base_type as $crate::db::api::view::EdgeViewOps<'static>>::Exploded {
self.$field.explode()
}

/// Explode layers returns an edge object for each layer within the original edge. These new edge object contains only updates from respective layers.
fn explode_layers(
&self,
) -> <$base_type as $crate::db::api::view::EdgeViewOps<'static>>::Exploded {
Expand Down

0 comments on commit 1584b5e

Please sign in to comment.