Skip to content

Commit

Permalink
Implement reading external sccs
Browse files Browse the repository at this point in the history
  • Loading branch information
kazuki0824 committed Dec 9, 2024
1 parent d67d6c9 commit 56bcc11
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/connectivity/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,23 @@ fn condensation_inner<N, E, Ty, Ix>(
py: &Python,
g: Graph<N, E, Ty, Ix>,
make_acyclic: bool,
sccs: Option<Vec<Vec<usize>>>,
) -> StableGraph<PyObject, PyObject, Ty, Ix>
where
Ty: EdgeType,
Ix: IndexType,
N: ToPyObject,
E: ToPyObject,
{
let sccs = kosaraju_scc(&g);
// Don't use into_iter to avoid extra allocations
let sccs = if let Some(sccs) = sccs {
sccs.iter()
.map(|row| row.iter().map(|x| NodeIndex::new(*x)).collect())
.collect()
} else {
kosaraju_scc(&g)
};

let mut condensed: StableGraph<Vec<N>, E, Ty, Ix> =
StableGraph::with_capacity(sccs.len(), g.edge_count());

Expand Down Expand Up @@ -167,12 +176,7 @@ pub fn condensation(
) -> digraph::PyDiGraph {
let g = graph.graph.clone();

// TODO: Override sccs from arg
let condensed = if let Some(_) = sccs {
unimplemented!("")
} else {
condensation_inner(&py, g.into(), true)
};
let condensed = condensation_inner(&py, g.into(), true, sccs);

digraph::PyDiGraph {
graph: condensed,
Expand Down

0 comments on commit 56bcc11

Please sign in to comment.