@@ -16,10 +16,14 @@ pub trait DirectedGraph {
1616 fn num_nodes ( & self ) -> usize ;
1717}
1818
19- pub trait WithNumEdges : DirectedGraph {
19+ pub trait NumEdges : DirectedGraph {
2020 fn num_edges ( & self ) -> usize ;
2121}
2222
23+ pub trait StartNode : DirectedGraph {
24+ fn start_node ( & self ) -> Self :: Node ;
25+ }
26+
2327pub trait Successors : DirectedGraph {
2428 type Successors < ' g > : Iterator < Item = Self :: Node >
2529 where
@@ -40,20 +44,16 @@ pub trait Predecessors: DirectedGraph {
4044 fn predecessors ( & self , node : Self :: Node ) -> Self :: Predecessors < ' _ > ;
4145}
4246
43- pub trait WithStartNode : DirectedGraph {
44- fn start_node ( & self ) -> Self :: Node ;
45- }
46-
47- pub trait ControlFlowGraph : DirectedGraph + WithStartNode + Predecessors + Successors {
47+ pub trait ControlFlowGraph : DirectedGraph + StartNode + Predecessors + Successors {
4848 // convenient trait
4949}
5050
51- impl < T > ControlFlowGraph for T where T : DirectedGraph + WithStartNode + Predecessors + Successors { }
51+ impl < T > ControlFlowGraph for T where T : DirectedGraph + StartNode + Predecessors + Successors { }
5252
5353/// Returns `true` if the graph has a cycle that is reachable from the start node.
5454pub fn is_cyclic < G > ( graph : & G ) -> bool
5555where
56- G : ?Sized + DirectedGraph + WithStartNode + Successors ,
56+ G : ?Sized + DirectedGraph + StartNode + Successors ,
5757{
5858 iterate:: TriColorDepthFirstSearch :: new ( graph)
5959 . run_from_start ( & mut iterate:: CycleDetector )
0 commit comments