strongly_connected_components/internal/
scc.rs1use crate::internal::node::Node;
2
3pub struct Scc {
7 pub(super) id: usize,
8 pub(super) nodes: Vec<Node>,
9}
10
11#[allow(clippy::len_without_is_empty)]
12impl Scc {
13 pub fn len(&self) -> usize {
15 self.nodes.len()
16 }
17
18 pub fn iter_nodes(&self) -> impl Iterator<Item = Node> {
21 self.nodes.iter().copied()
22 }
23}
24
25impl std::fmt::Debug for Scc {
26 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
27 write!(f, "Scc{:?}", self.nodes)
28 }
29}
30
31impl std::cmp::PartialEq for Scc {
32 fn eq(&self, other: &Self) -> bool {
33 self.id == other.id
34 }
35}
36
37impl std::cmp::Eq for Scc {}
38
39impl std::hash::Hash for Scc {
40 fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
41 self.id.hash(state);
42 }
43}