address review
This commit is contained in:
parent
c9843d6144
commit
8252a6eddf
5 changed files with 31 additions and 17 deletions
|
@ -21,21 +21,21 @@ mod tests;
|
|||
pub struct Sccs<N: Idx, S: Idx> {
|
||||
/// For each node, what is the SCC index of the SCC to which it
|
||||
/// belongs.
|
||||
pub scc_indices: IndexVec<N, S>,
|
||||
scc_indices: IndexVec<N, S>,
|
||||
|
||||
/// Data about each SCC.
|
||||
pub scc_data: SccData<S>,
|
||||
scc_data: SccData<S>,
|
||||
}
|
||||
|
||||
pub struct SccData<S: Idx> {
|
||||
/// For each SCC, the range of `all_successors` where its
|
||||
/// successors can be found.
|
||||
pub ranges: IndexVec<S, Range<usize>>,
|
||||
ranges: IndexVec<S, Range<usize>>,
|
||||
|
||||
/// Contains the successors for all the Sccs, concatenated. The
|
||||
/// range of indices corresponding to a given SCC is found in its
|
||||
/// SccData.
|
||||
pub all_successors: Vec<S>,
|
||||
all_successors: Vec<S>,
|
||||
}
|
||||
|
||||
impl<N: Idx, S: Idx + Ord> Sccs<N, S> {
|
||||
|
@ -43,6 +43,14 @@ impl<N: Idx, S: Idx + Ord> Sccs<N, S> {
|
|||
SccsConstruction::construct(graph)
|
||||
}
|
||||
|
||||
pub fn scc_indices(&self) -> &IndexVec<N, S> {
|
||||
&self.scc_indices
|
||||
}
|
||||
|
||||
pub fn scc_data(&self) -> &SccData<S> {
|
||||
&self.scc_data
|
||||
}
|
||||
|
||||
/// Returns the number of SCCs in the graph.
|
||||
pub fn num_sccs(&self) -> usize {
|
||||
self.scc_data.len()
|
||||
|
@ -115,6 +123,14 @@ impl<S: Idx> SccData<S> {
|
|||
self.ranges.len()
|
||||
}
|
||||
|
||||
pub fn ranges(&self) -> &IndexVec<S, Range<usize>> {
|
||||
&self.ranges
|
||||
}
|
||||
|
||||
pub fn all_successors(&self) -> &Vec<S> {
|
||||
&self.all_successors
|
||||
}
|
||||
|
||||
/// Returns the successors of the given SCC.
|
||||
fn successors(&self, scc: S) -> &[S] {
|
||||
// Annoyingly, `range` does not implement `Copy`, so we have
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue