diff --git a/raphtory-api/src/core/entities/mod.rs b/raphtory-api/src/core/entities/mod.rs index f54a972f1..a31da26bf 100644 --- a/raphtory-api/src/core/entities/mod.rs +++ b/raphtory-api/src/core/entities/mod.rs @@ -1,9 +1,12 @@ -use std::{borrow::Cow, fmt::{Display, Formatter}}; +use std::{ + borrow::Cow, + fmt::{Display, Formatter}, +}; -#[cfg(feature = "python")] -use pyo3::prelude::*; #[cfg(feature = "python")] use pyo3::exceptions::PyTypeError; +#[cfg(feature = "python")] +use pyo3::prelude::*; use serde::{Deserialize, Serialize}; use self::edges::edge_ref::EdgeRef; @@ -157,7 +160,6 @@ impl<'source> FromPyObject<'source> for GID { } } - #[derive(Copy, Clone, Debug, PartialEq, PartialOrd, Eq, Ord, Hash)] pub enum GidRef<'a> { U64(u64), diff --git a/raphtory/src/algorithms/community_detection/label_propagation.rs b/raphtory/src/algorithms/community_detection/label_propagation.rs index dd13a38cd..730e7938b 100644 --- a/raphtory/src/algorithms/community_detection/label_propagation.rs +++ b/raphtory/src/algorithms/community_detection/label_propagation.rs @@ -1,5 +1,5 @@ use rand::{rngs::StdRng, seq::SliceRandom, thread_rng, SeedableRng}; -use raphtory_api::core::entities::VID; +use raphtory_api::core::entities::GID; use std::collections::{BTreeMap, HashMap, HashSet}; use crate::{ @@ -25,12 +25,13 @@ pub fn label_propagation( where G: StaticGraphViewOps, { - let mut labels: Vec = Vec::with_capacity(graph.count_nodes()); - let nodes = graph.nodes(); - labels = nodes.iter().map(|n| n.node.0).collect(); + let mut labels: HashMap, GID> = HashMap::new(); + let nodes = &graph.nodes(); + for node in nodes.iter() { + labels.insert(node, node.id()); + } - let nodes = graph.nodes(); - let mut shuffled_nodes: Vec> = nodes.iter().collect(); + let mut shuffled_nodes: Vec> = nodes.iter().collect(); if let Some(seed_value) = seed { let mut rng = StdRng::from_seed(seed_value); shuffled_nodes.shuffle(&mut rng); @@ -43,16 +44,15 @@ where changed = false; for node in &shuffled_nodes { let neighbors = node.neighbours(); - let mut label_count: BTreeMap = BTreeMap::new(); + let mut label_count: BTreeMap = BTreeMap::new(); for neighbour in neighbors { - let key = labels[neighbour.node.0]; - *label_count.entry(key).or_insert(0.0) += 1.0; + *label_count.entry(labels[&neighbour].clone()).or_insert(0.0) += 1.0; } if let Some(max_label) = find_max_label(&label_count) { - if max_label != labels[node.node.0] { - labels[node.node.0] = max_label; + if max_label != labels[node] { + labels.insert(node.clone(), max_label); changed = true; } } @@ -60,20 +60,19 @@ where } // Group nodes by their labels to form communities - let mut communities: HashMap>> = HashMap::new(); - for (node, label) in labels.into_iter().enumerate() { - let node = graph.node(VID(node)).unwrap(); - communities.entry(label).or_default().insert(node); + let mut communities: HashMap>> = HashMap::new(); + for (node, label) in labels { + communities.entry(label).or_default().insert(node.cloned()); } Ok(communities.values().cloned().collect()) } -fn find_max_label(label_count: &BTreeMap) -> Option { +fn find_max_label(label_count: &BTreeMap) -> Option { label_count .iter() .max_by(|a, b| a.1.partial_cmp(b.1).unwrap()) - .map(|(label, _)| *label) + .map(|(label, _)| label.clone()) } #[cfg(test)] @@ -100,10 +99,16 @@ mod lpa_tests { for (ts, src, dst) in edges { graph.add_edge(ts, src, dst, NO_PROPS, None).unwrap(); } - test_storage!(&graph, |graph| { let seed = Some([5; 32]); let result = label_propagation(graph, seed).unwrap(); + + let ids = result + .iter() + .map(|n_set| n_set.iter().map(|n| n.node).collect::>()) + .collect::>(); + println!("{:?}", ids); + let expected = vec![ HashSet::from([ graph.node("R1").unwrap(), diff --git a/raphtory/src/algorithms/components/connected_components.rs b/raphtory/src/algorithms/components/connected_components.rs index 152dddbb0..f9c89e49b 100644 --- a/raphtory/src/algorithms/components/connected_components.rs +++ b/raphtory/src/algorithms/components/connected_components.rs @@ -2,7 +2,7 @@ use crate::{ algorithms::algorithm_result::AlgorithmResult, core::{entities::VID, state::compute_state::ComputeStateVec}, db::{ - api::view::{BaseNodeViewOps, NodeViewOps, StaticGraphViewOps}, + api::view::{NodeViewOps, StaticGraphViewOps}, task::{ context::Context, node::eval_node::EvalNodeView, @@ -13,7 +13,6 @@ use crate::{ }; use raphtory_api::core::entities::GID; use rayon::prelude::*; -use std::cmp; #[derive(Clone, Debug, Default)] struct WccState { @@ -280,7 +279,7 @@ mod cc_test { let vs = vs.into_iter().unique().collect::>(); - let smallest = vs.iter().min().unwrap(); + // let smallest = vs.iter().min().unwrap(); let first = vs[0]; @@ -299,7 +298,7 @@ mod cc_test { // now we do connected community_detection over window 0..1 let res = weakly_connected_components(graph, usize::MAX, None).group_by(); - let actual = res + let (node, size) = res .into_iter() .map(|(cc, group)| (cc, Reverse(group.len()))) .sorted_by(|l, r| l.1.cmp(&r.1)) @@ -308,7 +307,10 @@ mod cc_test { .next() .unwrap(); - assert_eq!(actual, (GID::U64(*smallest), edges.len())); + let node = graph.node(node).map(|node| node.node); + assert_eq!(node, Some(VID(0))); + + assert_eq!(size, edges.len()); }); } } diff --git a/raphtory/src/algorithms/components/lcc.rs b/raphtory/src/algorithms/components/lcc.rs index 38912315b..a6ab25501 100644 --- a/raphtory/src/algorithms/components/lcc.rs +++ b/raphtory/src/algorithms/components/lcc.rs @@ -34,7 +34,7 @@ impl LargestConnectedComponent for Graph { { let mut connected_components_map = weakly_connected_components(self, usize::MAX, None).group_by(); - let mut lcc_key:GID = GID::U64(0); + let mut lcc_key: GID = GID::U64(0); let mut key_length = 0; let mut is_tie = false; diff --git a/raphtory/src/algorithms/components/out_components.rs b/raphtory/src/algorithms/components/out_components.rs index 9ca7bd116..ca7b5bcb2 100644 --- a/raphtory/src/algorithms/components/out_components.rs +++ b/raphtory/src/algorithms/components/out_components.rs @@ -1,5 +1,3 @@ -use raphtory_api::core::entities::GID; -use rayon::prelude::*; use crate::{ algorithms::algorithm_result::AlgorithmResult, core::{entities::VID, state::compute_state::ComputeStateVec}, @@ -13,6 +11,8 @@ use crate::{ }, }, }; +use raphtory_api::core::entities::GID; +use rayon::prelude::*; use std::collections::HashSet; #[derive(Clone, Debug, Default)] @@ -77,7 +77,11 @@ where .par_iter() .map(|node| { let VID(id) = node.node; - let comps = local[id].out_components.iter().map(|vid| graph.node_id(*vid)).collect(); + let comps = local[id] + .out_components + .iter() + .map(|vid| graph.node_id(*vid)) + .collect(); (id, comps) }) .collect() diff --git a/raphtory/src/algorithms/pathing/temporal_reachability.rs b/raphtory/src/algorithms/pathing/temporal_reachability.rs index 2092e0529..df487e4fe 100644 --- a/raphtory/src/algorithms/pathing/temporal_reachability.rs +++ b/raphtory/src/algorithms/pathing/temporal_reachability.rs @@ -1,9 +1,12 @@ use crate::{ algorithms::algorithm_result::AlgorithmResult, - core::{entities::nodes::node_ref::AsNodeRef, state::{ - accumulator_id::accumulators::{hash_set, min, or}, - compute_state::ComputeStateVec, - }}, + core::{ + entities::nodes::node_ref::AsNodeRef, + state::{ + accumulator_id::accumulators::{hash_set, min, or}, + compute_state::ComputeStateVec, + }, + }, db::{ api::view::StaticGraphViewOps, task::{ @@ -17,7 +20,7 @@ use crate::{ }; use itertools::Itertools; use num_traits::Zero; -use raphtory_api::core::{entities::VID, input::input_node::InputNode}; +use raphtory_api::core::entities::VID; use std::{collections::HashMap, ops::Add}; #[derive(Eq, Hash, PartialEq, Clone, Debug, Default)] diff --git a/raphtory/src/core/entities/graph/tgraph.rs b/raphtory/src/core/entities/graph/tgraph.rs index 81ee0510b..944c52365 100644 --- a/raphtory/src/core/entities/graph/tgraph.rs +++ b/raphtory/src/core/entities/graph/tgraph.rs @@ -506,7 +506,11 @@ impl TemporalGraph { Some(*v_id) } NodeRef::ExternalStr(string) => { - let v_id = self.logical_to_physical.get(&GID::Str(string.to_owned()))?; + let v_id = self + .logical_to_physical + .get(&GID::Str(string.to_owned())) + .or_else(|| self.logical_to_physical.get(&GID::U64(string.id()))) + .or_else(|| self.logical_to_physical.get(&GID::I64(string.id() as i64)))?; Some(*v_id) } } diff --git a/raphtory/src/db/api/mutation/addition_ops.rs b/raphtory/src/db/api/mutation/addition_ops.rs index 7b8b7ee69..364c7f505 100644 --- a/raphtory/src/db/api/mutation/addition_ops.rs +++ b/raphtory/src/db/api/mutation/addition_ops.rs @@ -1,3 +1,4 @@ +use super::time_from_input; use crate::{ core::{ entities::{edges::edge_ref::EdgeRef, nodes::node_ref::AsNodeRef}, @@ -12,9 +13,6 @@ use crate::{ graph::{edge::EdgeView, node::NodeView}, }, }; -use raphtory_api::core::input::input_node::InputNode; - -use super::time_from_input; pub trait AdditionOps: StaticGraphViewOps { // TODO: Probably add vector reference here like add diff --git a/raphtory/src/db/api/mutation/deletion_ops.rs b/raphtory/src/db/api/mutation/deletion_ops.rs index 12cafbf8d..730606b2c 100644 --- a/raphtory/src/db/api/mutation/deletion_ops.rs +++ b/raphtory/src/db/api/mutation/deletion_ops.rs @@ -1,3 +1,4 @@ +use super::time_from_input; use crate::{ core::{ entities::nodes::node_ref::AsNodeRef, @@ -8,9 +9,6 @@ use crate::{ TryIntoInputTime, }, }; -use raphtory_api::core::input::input_node::InputNode; - -use super::time_from_input; pub trait DeletionOps: InternalDeletionOps + InternalAdditionOps + Sized { fn delete_edge( diff --git a/raphtory/src/db/api/mutation/import_ops.rs b/raphtory/src/db/api/mutation/import_ops.rs index c1eb81780..22e32488e 100644 --- a/raphtory/src/db/api/mutation/import_ops.rs +++ b/raphtory/src/db/api/mutation/import_ops.rs @@ -11,7 +11,6 @@ use crate::{ mutation::internal::{ InternalAdditionOps, InternalDeletionOps, InternalPropertyAdditionOps, }, - storage::nodes::node_storage_ops::NodeStorageOps, view::{internal::InternalMaterialize, IntoDynamic, StaticGraphViewOps}, }, graph::{edge::EdgeView, node::NodeView}, diff --git a/raphtory/src/db/api/view/graph.rs b/raphtory/src/db/api/view/graph.rs index cd37de3f1..87d006237 100644 --- a/raphtory/src/db/api/view/graph.rs +++ b/raphtory/src/db/api/view/graph.rs @@ -163,8 +163,8 @@ impl<'graph, G: BoxableGraphView + Sized + Clone + 'graph> GraphViewOps<'graph> for ee in ee.explode() { g.add_edge( ee.time().expect("exploded edge"), - ee.src().name(), - ee.dst().name(), + ee.src().id(), + ee.dst().id(), ee.properties().temporal().collect_properties(), layer_name, )?; @@ -186,17 +186,17 @@ impl<'graph, G: BoxableGraphView + Sized + Clone + 'graph> GraphViewOps<'graph> let v_type_string = v.node_type(); //stop it being dropped let v_type_str = v_type_string.as_str(); for h in v.history() { - g.add_node(h, v.name(), NO_PROPS, v_type_str)?; + g.add_node(h, v.id(), NO_PROPS, v_type_str)?; } for (name, prop_view) in v.properties().temporal().iter() { for (t, prop) in prop_view.iter() { - g.add_node(t, v.name(), [(name.clone(), prop)], v_type_str)?; + g.add_node(t, v.id(), [(name.clone(), prop)], v_type_str)?; } } let node = match g.node(v.id()) { Some(node) => node, - None => g.add_node(earliest, v.name(), NO_PROPS, v_type_str)?, + None => g.add_node(earliest, v.id(), NO_PROPS, v_type_str)?, }; node.add_constant_properties(v.properties().constant())?; @@ -502,12 +502,10 @@ mod test_materialize { g.add_edge(0, 1, 2, [("layer2", "2")], Some("2")).unwrap(); let gm = g.materialize().unwrap(); - assert!(gm - .nodes() - .name() - .values() - .collect::>() - .eq(&vec!["1", "2"])); + assert_eq!( + gm.nodes().name().values().collect::>(), + vec!["1", "2"] + ); assert!(!g .layers("2") diff --git a/raphtory/src/db/api/view/serialise.rs b/raphtory/src/db/api/view/serialise.rs index bece641a0..3793ff2b1 100644 --- a/raphtory/src/db/api/view/serialise.rs +++ b/raphtory/src/db/api/view/serialise.rs @@ -217,7 +217,7 @@ impl<'graph, G: GraphViewOps<'graph>> StableEncoder for G { }, }; serialise::Node { - gid: proto_gid, + gid: Some(proto_gid), vid: vid.0 as u64, name, } @@ -408,7 +408,8 @@ impl< // align the nodes for node in g.nodes { - let l_vid = graph.resolve_node(node.gid)?; + let gid = from_proto_gid(node.gid.and_then(|gid| gid.gid).expect("Missing GID")); + let l_vid = graph.resolve_node(gid)?; assert_eq!(l_vid, VID(node.vid as usize)); } @@ -575,6 +576,14 @@ impl< } } +fn from_proto_gid(gid: gid::Gid) -> GID { + match gid { + gid::Gid::GidU64(n) => GID::U64(n), + gid::Gid::GidI64(n) => GID::I64(n), + gid::Gid::GidStr(s) => GID::Str(s), + } +} + fn as_prop(prop_pair: &PropPair) -> (usize, Prop) { let PropPair { key, value } = prop_pair; let value = value.as_ref().expect("Missing prop value"); diff --git a/raphtory/src/db/graph/views/deletion_graph.rs b/raphtory/src/db/graph/views/deletion_graph.rs index bd7eee91e..e36963388 100644 --- a/raphtory/src/db/graph/views/deletion_graph.rs +++ b/raphtory/src/db/graph/views/deletion_graph.rs @@ -1277,9 +1277,15 @@ mod test_deletions { pg.add_edge(0, 0, 1, [("added", Prop::I64(0))], None) .unwrap(); pg.delete_edge(10, 0, 1, None).unwrap(); - assert_eq!(pg.edges().id().collect::>(), vec![(GID::U64(0), GID::U64(1))]); + assert_eq!( + pg.edges().id().collect::>(), + vec![(GID::U64(0), GID::U64(1))] + ); let g = pg.event_graph(); - assert_eq!(g.edges().id().collect::>(), vec![(GID::U64(0), GID::U64(1))]); + assert_eq!( + g.edges().id().collect::>(), + vec![(GID::U64(0), GID::U64(1))] + ); } } diff --git a/raphtory/src/db/graph/views/window_graph.rs b/raphtory/src/db/graph/views/window_graph.rs index 54f5ec1a8..3bc3f9cb0 100644 --- a/raphtory/src/db/graph/views/window_graph.rs +++ b/raphtory/src/db/graph/views/window_graph.rs @@ -1006,7 +1006,12 @@ mod views_test { test_storage!(&graph, |graph| { let wg = graph.window(-2, 0); - let actual = wg.nodes().id().values().filter_map(|id| id.to_u64()).collect::>(); + let actual = wg + .nodes() + .id() + .values() + .filter_map(|id| id.to_u64()) + .collect::>(); let expected = vec![1, 2]; diff --git a/raphtory/src/graph.proto b/raphtory/src/graph.proto index cbb481f16..79a3db10c 100644 --- a/raphtory/src/graph.proto +++ b/raphtory/src/graph.proto @@ -83,7 +83,7 @@ message GID { } message Node{ - uint64 GID = 1; + GID gid = 1; uint64 vid = 2; optional string name = 3; } diff --git a/raphtory/src/graphgen/mod.rs b/raphtory/src/graphgen/mod.rs index e0418287a..9e9ee5a39 100644 --- a/raphtory/src/graphgen/mod.rs +++ b/raphtory/src/graphgen/mod.rs @@ -1,4 +1,26 @@ //! Provides functionality for generating graphs for testing and benchmarking. +use rand::Rng; +use raphtory_api::core::entities::GID; + +use crate::prelude::*; + pub mod preferential_attachment; pub mod random_attachment; + +pub(crate) fn next_id<'graph, G: GraphViewOps<'graph>>(g: &G, max_gid: Option) -> GID { + let max_gid = max_gid.unwrap_or_else(|| g.nodes().id().max().unwrap_or(GID::U64(0))); + match max_gid { + GID::U64(id) => GID::U64(id + 1), + GID::I64(id) => GID::I64(id + 1), + GID::Str(_) => { + let mut rng = rand::thread_rng(); + loop { + let new_id = GID::Str(rng.gen::().to_string()); + if g.node(&new_id).is_none() { + break new_id; + } + } + } + } +} diff --git a/raphtory/src/graphgen/preferential_attachment.rs b/raphtory/src/graphgen/preferential_attachment.rs index 2f92602b8..72a992d09 100644 --- a/raphtory/src/graphgen/preferential_attachment.rs +++ b/raphtory/src/graphgen/preferential_attachment.rs @@ -20,8 +20,9 @@ use crate::{ prelude::{NodeStateOps, NO_PROPS}, }; use rand::{rngs::StdRng, Rng, SeedableRng}; -use raphtory_api::core::entities::{GID, VID}; -use std::collections::{HashMap, HashSet}; +use std::collections::HashSet; + +use super::next_id; /// Generates a graph using the preferential attachment model. /// @@ -62,45 +63,28 @@ pub fn ba_preferential_attachment( } else { rng = StdRng::from_entropy(); } - let mut latest_time = graph.end().unwrap_or(0); - let view = graph.window(i64::MIN, i64::MAX); - let mut ids = view.nodes().id().values().collect::>(); - let r: Vec = view.nodes().degree().values().collect(); - let mut degrees: HashMap = r; + let mut latest_time = graph.latest_time().unwrap_or(0); + let view = graph; + let mut ids = graph.nodes().id().values().collect::>(); + let mut degrees: Vec = view.nodes().degree().values().collect(); let mut edge_count: usize = degrees.iter().sum(); - let mut max_id: GID = match ids.iter().max() { - Some(gid) => gid.clone(), - None => GID::U64(0), - }; - - fn next_id(max_id: &GID, rng: &mut StdRng, ids: &HashSet) -> GID { - match max_id { - GID::U64(id) => GID::U64(*id + 1), - GID::I64(id) => GID::I64(*id + 1), - GID::Str(_) => loop { - let id: GID = rng.gen::().to_string().into(); - if !ids.contains(&id) { - return id; - } - }, - } - } + let mut max_id = next_id(view, ids.iter().max().cloned()); while ids.len() < edges_per_step { - max_id = next_id(&max_id, &mut rng, &ids); + max_id = next_id(view, Some(max_id)); graph .add_node(latest_time, &max_id, NO_PROPS, None) .map_err(|err| println!("{:?}", err)) .ok(); - degrees.insert(max_id, 0); - ids.insert(max_id); + degrees.push(0); + ids.push(max_id.clone()); } if graph.count_edges() < edges_per_step { - for (src, dst) in ids.iter().skip(1).zip(ids.iter()){ + for pos in 1..ids.len() { graph - .add_edge(latest_time, src, dst, NO_PROPS, None) + .add_edge(latest_time, &ids[pos], &ids[pos - 1], NO_PROPS, None) .expect("Not able to add edge"); edge_count += 2; degrees[pos] += 1; @@ -109,7 +93,7 @@ pub fn ba_preferential_attachment( } for _ in 0..nodes_to_add { - max_id += 1; + max_id = next_id(view, Some(max_id)); latest_time += 1; let mut normalisation = edge_count; let mut positions_to_skip: HashSet = HashSet::new(); @@ -129,13 +113,13 @@ pub fn ba_preferential_attachment( } } for pos in positions_to_skip { - let dst = ids[pos]; + let dst = &ids[pos]; degrees[pos] += 1; graph - .add_edge(latest_time, max_id, dst, NO_PROPS, None) + .add_edge(latest_time, &max_id, dst, NO_PROPS, None) .expect("Not able to add edge"); } - ids.push(max_id); + ids.push(max_id.clone()); degrees.push(edges_per_step); edge_count += edges_per_step * 2; } diff --git a/raphtory/src/graphgen/random_attachment.rs b/raphtory/src/graphgen/random_attachment.rs index b74f2591e..00df8f2dd 100644 --- a/raphtory/src/graphgen/random_attachment.rs +++ b/raphtory/src/graphgen/random_attachment.rs @@ -22,6 +22,8 @@ use crate::{ }; use rand::{rngs::StdRng, seq::SliceRandom, SeedableRng}; +use super::next_id; + /// Given a graph this function will add a user defined number of nodes, each with a /// user defined number of edges. /// This is an iterative algorithm where at each `step` a node is added and its neighbours @@ -58,29 +60,29 @@ pub fn random_attachment( rng = StdRng::from_entropy(); } let mut latest_time = graph.latest_time().unwrap_or(0); - let mut ids: Vec = graph.nodes().id().values().collect(); - let mut max_id = ids.iter().max().copied().unwrap_or(0); + let mut ids = graph.nodes().id().values().collect::>(); + let mut max_id = next_id(graph, ids.iter().max().cloned()); while ids.len() < edges_per_step { - max_id += 1; + max_id = next_id(graph, Some(max_id)); latest_time += 1; graph - .add_node(latest_time, max_id, NO_PROPS, None) + .add_node(latest_time, &max_id, NO_PROPS, None) .map_err(|err| println!("{:?}", err)) .ok(); - ids.push(max_id); + ids.push(max_id.clone()); } for _ in 0..nodes_to_add { let edges = ids.choose_multiple(&mut rng, edges_per_step); - max_id += 1; + max_id = next_id(graph, Some(max_id)); latest_time += 1; edges.for_each(|neighbour| { graph - .add_edge(latest_time, max_id, *neighbour, NO_PROPS, None) + .add_edge(latest_time, &max_id, neighbour, NO_PROPS, None) .expect("Not able to add edge"); }); - ids.push(max_id); + ids.push(max_id.clone()); } } diff --git a/raphtory/src/io/arrow/mod.rs b/raphtory/src/io/arrow/mod.rs index 0d155a348..5ba8b9054 100644 --- a/raphtory/src/io/arrow/mod.rs +++ b/raphtory/src/io/arrow/mod.rs @@ -76,9 +76,27 @@ mod test { assert_eq!( actual, vec![ - (GID::U64(1), GID::U64(2), Some(1), Some(Prop::F64(1.0)), Some(Prop::str("a"))), - (GID::U64(2), GID::U64(3), Some(2), Some(Prop::F64(2.0)), Some(Prop::str("b"))), - (GID::U64(3), GID::U64(4), Some(3), Some(Prop::F64(3.0)), Some(Prop::str("c"))), + ( + GID::U64(1), + GID::U64(2), + Some(1), + Some(Prop::F64(1.0)), + Some(Prop::str("a")) + ), + ( + GID::U64(2), + GID::U64(3), + Some(2), + Some(Prop::F64(2.0)), + Some(Prop::str("b")) + ), + ( + GID::U64(3), + GID::U64(4), + Some(3), + Some(Prop::F64(3.0)), + Some(Prop::str("c")) + ), ] ); } diff --git a/raphtory/src/python/graph/algorithm_result.rs b/raphtory/src/python/graph/algorithm_result.rs index 8fdb362f5..8df00548b 100644 --- a/raphtory/src/python/graph/algorithm_result.rs +++ b/raphtory/src/python/graph/algorithm_result.rs @@ -3,9 +3,9 @@ use crate::{ db::api::view::{internal::DynamicGraph, StaticGraphViewOps}, python::types::repr::{Repr, StructReprBuilder}, }; -use raphtory_api::core::entities::GID; use ordered_float::OrderedFloat; use pyo3::prelude::*; +use raphtory_api::core::entities::GID; impl Repr for AlgorithmResultRs { fn repr(&self) -> String { diff --git a/raphtory/src/python/graph/edges.rs b/raphtory/src/python/graph/edges.rs index 542eb8de1..0f6866e6b 100644 --- a/raphtory/src/python/graph/edges.rs +++ b/raphtory/src/python/graph/edges.rs @@ -18,8 +18,8 @@ use crate::{ wrappers::iterables::{ ArcStringIterable, ArcStringVecIterable, BoolIterable, GIDGIDIterable, I64Iterable, I64VecIterable, NestedArcStringIterable, NestedArcStringVecIterable, - NestedBoolIterable, NestedI64VecIterable, NestedOptionI64Iterable, - NestedGIDGIDIterable, NestedUtcDateTimeIterable, NestedVecUtcDateTimeIterable, + NestedBoolIterable, NestedGIDGIDIterable, NestedI64VecIterable, + NestedOptionI64Iterable, NestedUtcDateTimeIterable, NestedVecUtcDateTimeIterable, OptionI64Iterable, OptionUtcDateTimeIterable, OptionVecUtcDateTimeIterable, }, }, diff --git a/raphtory/src/python/graph/graph.rs b/raphtory/src/python/graph/graph.rs index 4b216c443..d5e89e492 100644 --- a/raphtory/src/python/graph/graph.rs +++ b/raphtory/src/python/graph/graph.rs @@ -3,7 +3,6 @@ //! This is the base class used to create a temporal graph, add nodes and edges, //! create windows, and query the graph with a variety of algorithms. //! In Python, this class wraps around the rust graph. -use raphtory_api::core::entities::GID; use crate::{ algorithms::components::LargestConnectedComponent, core::{entities::nodes::node_ref::NodeRef, utils::errors::GraphError}, @@ -32,7 +31,7 @@ use pyo3::{ prelude::*, types::{PyBytes, PyTuple}, }; -use raphtory_api::core::storage::arc_str::ArcStr; +use raphtory_api::core::{entities::GID, storage::arc_str::ArcStr}; use std::{ collections::HashMap, fmt::{Debug, Formatter}, diff --git a/raphtory/src/python/graph/graph_with_deletions.rs b/raphtory/src/python/graph/graph_with_deletions.rs index 245b5a466..78117b64e 100644 --- a/raphtory/src/python/graph/graph_with_deletions.rs +++ b/raphtory/src/python/graph/graph_with_deletions.rs @@ -5,7 +5,6 @@ //! create windows, and query the graph with a variety of algorithms. //! It is a wrapper around a set of shards, which are the actual graph data structures. //! In Python, this class wraps around the rust graph. -use raphtory_api::core::entities::GID; use crate::{ core::{entities::nodes::node_ref::NodeRef, utils::errors::GraphError, Prop}, db::{ @@ -25,7 +24,7 @@ use crate::{ }, }; use pyo3::{prelude::*, types::PyBytes}; -use raphtory_api::core::storage::arc_str::ArcStr; +use raphtory_api::core::{entities::GID, storage::arc_str::ArcStr}; use std::{ collections::HashMap, fmt::{Debug, Formatter}, diff --git a/raphtory/src/python/types/wrappers/iterables.rs b/raphtory/src/python/types/wrappers/iterables.rs index abc42c3d8..400b12de2 100644 --- a/raphtory/src/python/types/wrappers/iterables.rs +++ b/raphtory/src/python/types/wrappers/iterables.rs @@ -2,8 +2,7 @@ use crate::{db::api::view::BoxedIter, prelude::Prop, python::types::repr::Repr}; use chrono::{DateTime, Utc}; use num::cast::AsPrimitive; use pyo3::prelude::*; -use raphtory_api::core::entities::GID; -use raphtory_api::core::storage::arc_str::ArcStr; +use raphtory_api::core::{entities::GID, storage::arc_str::ArcStr}; use std::{i64, iter::Sum}; pub(crate) trait MeanExt: Iterator diff --git a/raphtory/src/python/utils/mod.rs b/raphtory/src/python/utils/mod.rs index f5cbe1de8..eac713820 100644 --- a/raphtory/src/python/utils/mod.rs +++ b/raphtory/src/python/utils/mod.rs @@ -13,7 +13,6 @@ use crate::{ }; use chrono::{DateTime, Utc}; use pyo3::{exceptions::PyTypeError, prelude::*, types::PyDateTime}; -use raphtory_api::core::{entities::GID, input::input_node::InputNode}; use std::{future::Future, thread}; pub mod errors; diff --git a/raphtory/src/vectors/entity_id.rs b/raphtory/src/vectors/entity_id.rs index 466cff6ab..af12bc409 100644 --- a/raphtory/src/vectors/entity_id.rs +++ b/raphtory/src/vectors/entity_id.rs @@ -6,7 +6,7 @@ use crate::{ prelude::{EdgeViewOps, NodeViewOps}, }; use raphtory_api::core::entities::GID; -use serde::{Deserialize, Serialize, Serializer}; +use serde::{Deserialize, Serialize}; use std::fmt::{Display, Formatter}; #[derive(Clone, Debug, Eq, PartialEq, Hash, Serialize, Deserialize)]