use std::ops::{Index, Range};
use traitgraph::interface::{GraphBase, StaticGraph};
use traitgraph::walks::VecNodeWalk;
use traitsequence::interface::Sequence;
pub mod strongly_connected_macronode_algorithm;
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct Macronodes<Graph: GraphBase> {
macronodes: Vec<VecNodeWalk<Graph>>,
}
impl<Graph: GraphBase> Sequence<VecNodeWalk<Graph>, [VecNodeWalk<Graph>]> for Macronodes<Graph> {
type Iterator<'a> = std::slice::Iter<'a, VecNodeWalk<Graph>> where Self: 'a;
fn iter(&self) -> Self::Iterator<'_> {
self.macronodes.iter()
}
fn len(&self) -> usize {
self.macronodes.len()
}
}
impl<Graph: GraphBase> Index<usize> for Macronodes<Graph> {
type Output = VecNodeWalk<Graph>;
fn index(&self, index: usize) -> &Self::Output {
&self.macronodes[index]
}
}
impl<Graph: GraphBase> Index<Range<usize>> for Macronodes<Graph> {
type Output = [VecNodeWalk<Graph>];
fn index(&self, range: Range<usize>) -> &Self::Output {
&self.macronodes[range]
}
}
impl<Graph: GraphBase> From<Vec<VecNodeWalk<Graph>>> for Macronodes<Graph> {
fn from(macronodes: Vec<VecNodeWalk<Graph>>) -> Self {
Self { macronodes }
}
}
pub trait MacronodeAlgorithm<Graph: StaticGraph> {
fn compute_macronodes(graph: &Graph) -> Macronodes<Graph>;
}