1
+ /** *****************************************************************************
2
+ * Copyright (c) 2014 Guillaume DUBUISSON DUPLESSIS <guillaume.dubuisson_duplessis@insa-rouen.fr>.
3
+ * All rights reserved. This program and the accompanying materials
4
+ * are made available under the terms of the GNU Public License v3.0
5
+ * which accompanies this distribution, and is available at
6
+ * http://www.gnu.org/licenses/gpl.html
7
+ *
8
+ * Contributors:
9
+ * Guillaume DUBUISSON DUPLESSIS <guillaume.dubuisson_duplessis@insa-rouen.fr> - initial API and implementation
10
+ ******************************************************************************/
1
11
package graphs .P82
2
12
3
13
import util .ExerciseTemplate
@@ -13,12 +23,12 @@ trait P82Graph extends ExerciseTemplate with Graphs with graph.EdgesAsPairs {
13
23
res0: List[List[String]] = List(List(f, c, b, f), List(f, b, c, f))
14
24
*/
15
25
val name = " P82 (Cycle from a given node)"
16
- def findsCycles (graph : Graph , start : Node , end : Node ): List [List [Node ]]
26
+ def findsCycles (graph : Graph , start : Node ): List [List [Node ]]
17
27
18
28
type Node = Char
19
29
test(" Invoking findsCycles with the same start and end node should not return a cycle" ) {
20
30
val graph = newGraph(Set ('a' ), Set ())
21
- assert(findsCycles(graph, 'a' , 'a' ) == List ())
31
+ assert(findsCycles(graph, 'a' ) == List ())
22
32
}
23
33
24
34
test(" Invoking findsCycles should return all the cycles starting at a given node" ) {
@@ -31,7 +41,7 @@ trait P82Graph extends ExerciseTemplate with Graphs with graph.EdgesAsPairs {
31
41
*/
32
42
val graph = newGraph(Set ('a' , 'b' , 'c' , 'd' ), Set (('a' , 'b' ), ('b' , 'c' ), ('b' , 'd' ), ('c' , 'd' ), ('c' , 'a' ), ('d' , 'a' )))
33
43
34
- val cycles = findsCycles(graph, 'a' , 'd ' )
44
+ val cycles = findsCycles(graph, 'b ' )
35
45
assert(cycles.size == 15 )
36
46
assert(cycles.contains(List ('b' , 'a' , 'c' , 'd' , 'b' )))
37
47
assert(cycles.contains(List ('b' , 'd' , 'c' , 'a' , 'b' )))
0 commit comments