-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
#![cfg(test)]
-use graph::test::TestGraph;
+use crate::graph::test::TestGraph;
use super::*;
#[test]
#[test]
fn test_find_state_2() {
// The order in which things will be visited is important to this
- // test. It tests part of the `find_state` behavior.
+ // test. It tests part of the `find_state` behavior. Here is the
+ // graph:
+ //
//
- // We will start in our DFS by visiting:
+ // /----+
+ // 0 <--+ |
+ // | | |
+ // v | |
+ // +-> 1 -> 3 4
+ // | | |
+ // | v |
+ // +-- 2 <----+
+
+ let graph = TestGraph::new(0, &[
+ (0, 1),
+ (0, 4),
+ (1, 2),
+ (1, 3),
+ (2, 1),
+ (3, 0),
+ (4, 2),
+ ]);
+
+ // For this graph, we will start in our DFS by visiting:
//
// 0 -> 1 -> 2 -> 1
//
// 2 InCycleWith { 1 }
// 3 InCycleWith { 0 }
- /*
- /----+
- 0 <--+ |
- | | |
- v | |
-+-> 1 -> 3 4
-| | |
-| v |
-+-- 2 <----+
- */
- let graph = TestGraph::new(0, &[
- (0, 1),
- (0, 4),
- (1, 2),
- (1, 3),
- (2, 1),
- (3, 0),
- (4, 2),
- ]);
let sccs: Sccs<_, usize> = Sccs::new(&graph);
assert_eq!(sccs.num_sccs(), 1);
assert_eq!(sccs.scc(0), 0);