MCPcopy Index your code
hub / github.com/TheAlgorithms/Go / getTestGraphs

Function getTestGraphs

graph/coloring/graph_test.go:18–119  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

16}
17
18func getTestGraphs() (list []*testGraph) {
19 // Graph 0th:
20 // 1---2
21 // | / \
22 // 4---3 0
23 // Min number of colors required = 3
24 g0 := &testGraph{
25 Graph: &coloring.Graph{},
26 ColorsUsed: 3,
27 VertexColors: map[int]coloring.Color{
28 1: 1, 4: 1, 0: 1,
29 2: 2,
30 3: 3,
31 },
32 }
33 list = append(list, g0)
34 g0.Graph.AddEdge(4, 3)
35 g0.Graph.AddEdge(3, 1)
36 g0.Graph.AddEdge(3, 2)
37 g0.Graph.AddEdge(1, 2)
38 g0.Graph.AddEdge(2, 0)
39
40 // Graph 1st:
41 // 1---2
42 // | / |
43 // 4---3---0
44 // Min number of colors required = 3
45 g1 := &testGraph{
46 Graph: &coloring.Graph{},
47 ColorsUsed: 3,
48 VertexColors: map[int]coloring.Color{
49 1: 1, 4: 1, 0: 1,
50 2: 2,
51 3: 3,
52 },
53 }
54 list = append(list, g1)
55 g1.Graph.AddEdge(4, 3)
56 g1.Graph.AddEdge(3, 1)
57 g1.Graph.AddEdge(3, 2)
58 g1.Graph.AddEdge(1, 2)
59 g1.Graph.AddEdge(2, 0)
60 g1.Graph.AddEdge(3, 0)
61
62 // Graph 2nd:
63 // 1---2
64 // |
65 // 4---3 0
66 // Min number of colors required = 2
67 g2 := &testGraph{
68 Graph: &coloring.Graph{},
69 ColorsUsed: 2,
70 VertexColors: map[int]coloring.Color{
71 1: 1, 4: 1, 0: 1,
72 2: 2, 3: 2,
73 },
74 }
75 list = append(list, g2)

Calls 2

AddEdgeMethod · 0.45
AddVertexMethod · 0.45

Tested by

no test coverage detected