From 1539e7e20c9acaf9a11f5ea9cc3aba278f296086 Mon Sep 17 00:00:00 2001 From: wyatt-joyner-pometry Date: Wed, 18 Dec 2024 09:59:50 +0000 Subject: [PATCH] remove early-culling code from SCC (#1895) * remove early-culling code from SCC * apply formatting accidentally discarded my formatting changes in the last commit- doh! --- raphtory/src/algorithms/components/scc.rs | 46 ++++++---------------- raphtory/src/python/packages/algorithms.rs | 2 +- 2 files changed, 14 insertions(+), 34 deletions(-) diff --git a/raphtory/src/algorithms/components/scc.rs b/raphtory/src/algorithms/components/scc.rs index 08449ea05..a9342982b 100644 --- a/raphtory/src/algorithms/components/scc.rs +++ b/raphtory/src/algorithms/components/scc.rs @@ -1,23 +1,9 @@ -use std::{ - collections::{HashMap, HashSet}, - fmt::Debug, -}; - -use itertools::Itertools; +use std::collections::{HashMap, HashSet}; use crate::{ algorithms::algorithm_result::AlgorithmResult, - core::{entities::VID, state::compute_state::ComputeStateVec}, - db::{ - api::view::StaticGraphViewOps, - graph::node::NodeView, - task::{ - context::Context, - node::eval_node::EvalNodeView, - task::{ATask, Job, Step}, - task_runner::TaskRunner, - }, - }, + core::entities::VID, + db::{api::view::StaticGraphViewOps, graph::node::NodeView}, prelude::*, }; @@ -88,13 +74,12 @@ where result } -pub fn strongly_connected_components( - graph: &G, - threads: Option, -) -> AlgorithmResult +pub fn strongly_connected_components(graph: &G) -> AlgorithmResult where G: StaticGraphViewOps, { + // TODO: evaluate/improve this early-culling code + /* #[derive(Clone, Debug, Default)] struct SCCNode { is_scc_node: bool, @@ -147,22 +132,17 @@ where .filter(|(_, state)| state.is_scc_node) .map(|(vid, _)| VID(vid)), ); + */ + let results_type = std::any::type_name::(); - let groups = tarjan_scc(&sub_graph); + let groups = tarjan_scc(graph); - let mut id = groups.len(); let mut res = HashMap::new(); for (id, group) in groups.into_iter().enumerate() { for VID(node) in group { res.insert(node, id); } } - for (node, state) in local.into_iter().enumerate() { - if !state.is_scc_node { - res.insert(node, id); - id += 1; - } - } AlgorithmResult::new( graph.clone(), @@ -202,7 +182,7 @@ mod strongly_connected_components_tests { } test_storage!(&graph, |graph| { - let scc_nodes: HashSet<_> = strongly_connected_components(graph, None) + let scc_nodes: HashSet<_> = strongly_connected_components(graph) .group_by() .into_values() .map(|mut v| { @@ -246,7 +226,7 @@ mod strongly_connected_components_tests { } test_storage!(&graph, |graph| { - let scc_nodes: HashSet<_> = strongly_connected_components(graph, None) + let scc_nodes: HashSet<_> = strongly_connected_components(graph) .group_by() .into_values() .map(|mut v| { @@ -273,7 +253,7 @@ mod strongly_connected_components_tests { } test_storage!(&graph, |graph| { - let scc_nodes: HashSet<_> = strongly_connected_components(graph, None) + let scc_nodes: HashSet<_> = strongly_connected_components(graph) .group_by() .into_values() .map(|mut v| { @@ -308,7 +288,7 @@ mod strongly_connected_components_tests { } test_storage!(&graph, |graph| { - let scc_nodes: HashSet<_> = strongly_connected_components(graph, None) + let scc_nodes: HashSet<_> = strongly_connected_components(graph) .group_by() .into_values() .map(|mut v| { diff --git a/raphtory/src/python/packages/algorithms.rs b/raphtory/src/python/packages/algorithms.rs index aec487d5c..b61509c5a 100644 --- a/raphtory/src/python/packages/algorithms.rs +++ b/raphtory/src/python/packages/algorithms.rs @@ -125,7 +125,7 @@ pub fn weakly_connected_components( pub fn strongly_connected_components( g: &PyGraphView, ) -> AlgorithmResult { - components::strongly_connected_components(&g.graph, None) + components::strongly_connected_components(&g.graph) } #[cfg(feature = "storage")]