1 use super::indexed_vec::Idx;
4 pub mod implementation;
13 pub trait DirectedGraph {
17 pub trait WithNumNodes: DirectedGraph {
18 fn num_nodes(&self) -> usize;
21 pub trait WithNumEdges: DirectedGraph {
22 fn num_edges(&self) -> usize;
25 pub trait WithSuccessors: DirectedGraph
27 Self: for<'graph> GraphSuccessors<'graph, Item = <Self as DirectedGraph>::Node>,
32 ) -> <Self as GraphSuccessors<'_>>::Iter;
34 fn depth_first_search(&self, from: Self::Node) -> iterate::DepthFirstSearch<'_, Self>
38 iterate::DepthFirstSearch::new(self, from)
42 #[allow(unused_lifetimes)]
43 pub trait GraphSuccessors<'graph> {
45 type Iter: Iterator<Item = Self::Item>;
48 pub trait WithPredecessors: DirectedGraph
50 Self: for<'graph> GraphPredecessors<'graph, Item = <Self as DirectedGraph>::Node>,
55 ) -> <Self as GraphPredecessors<'_>>::Iter;
58 #[allow(unused_lifetimes)]
59 pub trait GraphPredecessors<'graph> {
61 type Iter: Iterator<Item = Self::Item>;
64 pub trait WithStartNode: DirectedGraph {
65 fn start_node(&self) -> Self::Node;
68 pub trait ControlFlowGraph:
69 DirectedGraph + WithStartNode + WithPredecessors + WithStartNode + WithSuccessors + WithNumNodes
74 impl<T> ControlFlowGraph for T