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

Function TestPrimMST

graph/prim_test.go:9–143  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

7)
8
9func TestPrimMST(t *testing.T) {
10
11 var testCases = []struct {
12 edges []Edge
13 vertices int
14 start int
15 cost int
16 mst []Edge
17 }{
18 {
19 edges: []Edge{
20 {Start: 0, End: 1, Weight: 4},
21 {Start: 0, End: 2, Weight: 13},
22 {Start: 0, End: 3, Weight: 7},
23 {Start: 0, End: 4, Weight: 7},
24 {Start: 1, End: 2, Weight: 9},
25 {Start: 1, End: 3, Weight: 3},
26 {Start: 1, End: 4, Weight: 7},
27 {Start: 2, End: 3, Weight: 10},
28 {Start: 2, End: 4, Weight: 14},
29 {Start: 3, End: 4, Weight: 4},
30 },
31 vertices: 5,
32 start: 0,
33 cost: 20,
34 mst: []Edge{
35 {Start: 0, End: 1, Weight: 4},
36 {Start: 1, End: 3, Weight: 3},
37 {Start: 3, End: 4, Weight: 4},
38 {Start: 1, End: 2, Weight: 9},
39 },
40 },
41 {
42 edges: []Edge{
43 {Start: 0, End: 1, Weight: 4},
44 {Start: 0, End: 7, Weight: 8},
45 {Start: 1, End: 2, Weight: 8},
46 {Start: 1, End: 7, Weight: 11},
47 {Start: 2, End: 3, Weight: 7},
48 {Start: 2, End: 5, Weight: 4},
49 {Start: 2, End: 8, Weight: 2},
50 {Start: 3, End: 4, Weight: 9},
51 {Start: 3, End: 5, Weight: 14},
52 {Start: 4, End: 5, Weight: 10},
53 {Start: 5, End: 6, Weight: 2},
54 {Start: 6, End: 7, Weight: 1},
55 {Start: 6, End: 8, Weight: 6},
56 {Start: 7, End: 8, Weight: 7},
57 },
58 vertices: 9,
59 start: 3,
60 cost: 37,
61 mst: []Edge{
62 {Start: 3, End: 2, Weight: 7},
63 {Start: 2, End: 8, Weight: 2},
64 {Start: 2, End: 5, Weight: 4},
65 {Start: 5, End: 6, Weight: 2},
66 {Start: 6, End: 7, Weight: 1},

Callers

nothing calls this directly

Calls 4

VertexTypeAlias · 0.85
AddWeightedEdgeMethod · 0.80
PrimMSTMethod · 0.80
NewFunction · 0.70

Tested by

no test coverage detected