diff --git a/raphtory/src/db/api/view/graph.rs b/raphtory/src/db/api/view/graph.rs index 3b28576ee..1aa76e7be 100644 --- a/raphtory/src/db/api/view/graph.rs +++ b/raphtory/src/db/api/view/graph.rs @@ -337,11 +337,6 @@ impl<'graph, G: BoxableGraphView + Sized + Clone + 'graph> GraphViewOps<'graph> } fn subgraph, V: AsNodeRef>(&self, nodes: I) -> NodeSubgraph { - let _layer_ids = self.layer_ids(); - let nodes: FxHashSet = nodes - .into_iter() - .flat_map(|v| (&self).node(v).map(|v| v.node)) - .collect(); NodeSubgraph::new(self.clone(), nodes) } diff --git a/raphtory/src/db/graph/views/node_subgraph.rs b/raphtory/src/db/graph/views/node_subgraph.rs index b362845cf..a50a2e932 100644 --- a/raphtory/src/db/graph/views/node_subgraph.rs +++ b/raphtory/src/db/graph/views/node_subgraph.rs @@ -1,5 +1,5 @@ use crate::{ - core::entities::{LayerIds, VID}, + core::entities::{nodes::node_ref::AsNodeRef, LayerIds, VID}, db::api::{ properties::internal::InheritPropertiesOps, state::Index, @@ -50,11 +50,14 @@ impl<'graph, G: GraphViewOps<'graph>> InheritMaterialize for NodeSubgraph {} impl<'graph, G: GraphViewOps<'graph>> InheritLayerOps for NodeSubgraph {} impl<'graph, G: GraphViewOps<'graph>> NodeSubgraph { - pub fn new(graph: G, nodes: impl IntoIterator) -> Self { + pub fn new(graph: G, nodes: impl IntoIterator) -> Self { + let nodes = nodes + .into_iter() + .flat_map(|v| graph.internalise_node(v.as_node_ref())); let mut nodes: Vec<_> = if graph.nodes_filtered() { - nodes.into_iter().filter(|n| graph.has_node(*n)).collect() + nodes.filter(|n| graph.has_node(*n)).collect() } else { - nodes.into_iter().collect() + nodes.collect() }; nodes.sort(); let nodes = Index::new(nodes, graph.unfiltered_num_nodes());