(t *testing.T)
| 25 | } |
| 26 | |
| 27 | func TestFindAllCycles(t *testing.T) { |
| 28 | graph := Graph{Directed: true} |
| 29 | edges := [][]int{{0, 4}, {1, 3}, {2, 3}, {3, 4}, {4, 7}, {5, 2}, {6, 3}, {7, 3}} |
| 30 | for _, edge := range edges { |
| 31 | graph.AddEdge(edge[0], edge[1]) |
| 32 | } |
| 33 | |
| 34 | res := graph.FindAllCycles() |
| 35 | |
| 36 | if len(res) != 1 { |
| 37 | t.Error("number of cycles is not correct") |
| 38 | } |
| 39 | |
| 40 | firstCycle := res[0] |
| 41 | if len(firstCycle.edges) != 3 { |
| 42 | t.Error("number of vertex in cycle is not correct") |
| 43 | } |
| 44 | if _, ok := firstCycle.edges[3][4]; !ok { |
| 45 | t.Error("connection in cycle is not correct") |
| 46 | } |
| 47 | if _, ok := firstCycle.edges[4][7]; !ok { |
| 48 | t.Error("connection in cycle is not correct") |
| 49 | } |
| 50 | if _, ok := firstCycle.edges[7][3]; !ok { |
| 51 | t.Error("connection in cycle is not correct") |
| 52 | } |
| 53 | } |
nothing calls this directly
no test coverage detected