Skip to content

Commit d78cdaf

Browse files
committed
Implement scc
1 parent 42aadfb commit d78cdaf

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/scc.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,25 @@
1+
use crate::internal_scc;
2+
3+
pub struct SccGraph {
4+
internal: internal_scc::SccGraph,
5+
}
6+
7+
impl SccGraph {
8+
pub fn new(n: usize) -> Self {
9+
SccGraph {
10+
internal: internal_scc::SccGraph::new(n),
11+
}
12+
}
13+
14+
pub fn add_edge(&mut self, from: usize, to: usize) {
15+
let n = self.internal.num_vertices();
16+
assert!(from < n);
17+
assert!(to < n);
18+
self.internal.add_edge(from, to);
19+
}
20+
21+
pub fn scc(&self) -> Vec<Vec<usize>> {
22+
self.internal.scc()
23+
}
24+
}
125

0 commit comments

Comments
 (0)