@@ -142,6 +142,39 @@ fn test_petgraph() {
142142 // Outputs are a pseudo node
143143 assert_eq ! ( graph. node_count( ) , 4 ) ;
144144 assert_eq ! ( graph. edge_count( ) , 3 ) ;
145+
146+ // Ayclic graph should have no feedback arcs.
147+ let mut arcs = petgraph. greedy_feedback_arcs ( ) ;
148+ assert ! ( arcs. next( ) . is_none( ) ) ;
149+ }
150+
151+ #[ cfg( feature = "graph" ) ]
152+ #[ test]
153+ fn test_feedback_arcs ( ) {
154+ use safety_net:: MultiDiGraph ;
155+
156+ let netlist = divider_netlist ( ) ;
157+
158+ let petgraph = netlist. get_analysis :: < MultiDiGraph < _ > > ( ) ;
159+ assert ! ( petgraph. is_ok( ) ) ;
160+ let petgraph = petgraph. unwrap ( ) ;
161+
162+ // Has exactly one arc
163+ let mut arcs = petgraph. greedy_feedback_arcs ( ) ;
164+ let arc = arcs. next ( ) ;
165+ assert ! ( arc. is_some( ) ) ;
166+ assert ! ( arcs. next( ) . is_none( ) ) ;
167+
168+ // Disconnect the arc
169+ let arc = arc. unwrap ( ) ;
170+ arc. target ( ) . disconnect ( ) ;
171+
172+ // Should be acyclic now
173+ let petgraph = netlist. get_analysis :: < MultiDiGraph < _ > > ( ) ;
174+ assert ! ( petgraph. is_ok( ) ) ;
175+ let petgraph = petgraph. unwrap ( ) ;
176+ let mut arcs = petgraph. greedy_feedback_arcs ( ) ;
177+ assert ! ( arcs. next( ) . is_none( ) ) ;
145178}
146179
147180#[ test]
0 commit comments