-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgraphgen_print_test.go
149 lines (139 loc) · 4.96 KB
/
graphgen_print_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
package main
import (
"testing"
"github.com/fatih/color"
"github.com/arangodb/feed/pkg/graphgen"
)
func TestPrintPath(t *testing.T) {
const length uint64 = 3
const directed bool = true
const startV uint64 = 1
const startE uint64 = 2
const prefix string = "pr"
gg, err := (&graphgen.PathParameters{
length, directed, 64, graphgen.GeneralParameters{prefix, "", startV,
startE}}).MakeGraphGenerator(true, true)
if err != nil {
t.Error("Error in graphgen.PathParameters: ", err)
}
color.Cyan("Directed path, length %d, startIndexVertices %d, startIndexEdges %d",
length, startV, startE)
graphgen.PrintGraph(&gg)
}
func TestPrintUndirectedPath(t *testing.T) {
var length uint64 = 2
var directed bool = false
const startV uint64 = 1
const startE uint64 = 2
const prefix string = "pr"
gg, err := (&graphgen.PathParameters{
length, directed, 64, graphgen.GeneralParameters{prefix, "", startV,
startE}}).MakeGraphGenerator(true, true)
if err != nil {
t.Error("Error in graphgen.PathParameters: ", err)
}
color.Cyan("Undirected path, length %d, startIndexVertices %d, startIndexEdges %d",
length, startV, startE)
graphgen.PrintGraph(&gg)
}
func TestPrintDownTree(t *testing.T) {
const branchingDegree uint64 = 3
const depth uint64 = 2
const directionType string = "downwards"
const startV uint64 = 1
const startE uint64 = 2
const prefix string = "pr"
gg, err := (&graphgen.CompleteNaryTreeParameters{
branchingDegree, depth, directionType, 64,
graphgen.GeneralParameters{prefix, "", startV, startE}}).MakeGraphGenerator(true, true)
if err != nil {
t.Error("Error in graphgen.CompleteNaryTreeParameters: ", err)
}
color.Cyan("Downward tree, branch %d, depth %d, directionType %s, startIndexVertices %d, startIndexEdges %d",
branchingDegree, depth, directionType, startV, startE)
graphgen.PrintGraph(&gg)
}
func TestPrintDirectedCycle(t *testing.T) {
const length uint64 = 3
const startV uint64 = 1
const startE uint64 = 2
const prefix string = "pr"
gg, err := (&graphgen.CycleGraphParameters{
length, 64, graphgen.GeneralParameters{prefix, "", startV,
startE}}).MakeGraphGenerator(true, true)
if err != nil {
t.Error("Error in graphgen.CycleGraphParameters: ", err)
}
color.Cyan("Directed cycle, length %d, startIndexVertices %d, startIndexEdges %d",
length, startV, startE)
graphgen.PrintGraph(&gg)
}
func TestPrintEdgeless(t *testing.T) {
const size uint64 = 5
const startV uint64 = 1
const startE uint64 = 2
const prefix string = "pr"
gg, err := (&graphgen.EdgelessGraphParameters{
size, 64, graphgen.GeneralParameters{prefix, "", startV,
startE}}).MakeGraphGenerator(true, true)
if err != nil {
t.Error("Error in graphgen.EdgelessGraphParameters: ", err)
}
color.Cyan("Edgeless graph, size %d, startIndexVertices %d, startIndexEdges %d",
size, startV, startE)
graphgen.PrintGraph(&gg)
}
func TestPrintUnionPathTree(t *testing.T) {
const length uint64 = 2
const directed bool = true
const branchingDegree uint64 = 2
const depth uint64 = 1
const directionType string = "upwards"
const startV uint64 = 1
const startE uint64 = 2
const prefix string = "pr"
gg, err := (&graphgen.UnionParameters{
&graphgen.PathParameters{length, directed, 64, graphgen.GeneralParameters{
"a", "", startV, startE}},
&graphgen.CompleteNaryTreeParameters{branchingDegree, depth,
directionType, 64, graphgen.GeneralParameters{
"b", "", startV + length + 1, startE + length}},
graphgen.GeneralParameters{prefix, "", startV, startE}}).MakeGraphGenerator(true, true)
if err != nil {
t.Error("Error in graphgen.UnionParameters: ", err)
}
const formatString string = "Union of a path " +
"(length %d, directed %t) and a " +
"tree (branching %d, depth %d, type %s),\nprefix %s, " +
"startIndexVertices %d, startIndexEdges %d"
color.Cyan(formatString, length, directed, branchingDegree, depth,
directionType, prefix, startV, startE)
graphgen.PrintGraph(&gg)
}
func TestPrintLexprodPathTree(t *testing.T) {
const length uint64 = 2
const directed bool = true
const branchingDegree uint64 = 2
const depth uint64 = 1
const directionType string = "upwards"
const startV uint64 = 1
const startE uint64 = 2
const prefix = "pr"
gg, err := (&graphgen.LexicographicalProductParameters{
&graphgen.PathParameters{length, directed, 64, graphgen.GeneralParameters{
"a", "", startV, startE}},
&graphgen.CompleteNaryTreeParameters{branchingDegree, depth,
directionType, 64, graphgen.GeneralParameters{
"b", "", startV + length + 1, startE + length}},
graphgen.GeneralParameters{prefix, "", startV, startE}}).MakeGraphGenerator(true, true)
if err != nil {
t.Error("Error in graphgen.UnionParameters: ", err)
}
const formatString string = "Lexicographical product of a path " +
"(length %d, directed %t) and\na " +
"tree (branching %d, depth %d, type %s),\nprefix %s, " +
"startIndexVertices %d, startIndexEdges %d"
color.Cyan(formatString, length, directed, branchingDegree, depth,
directionType, prefix, startV, startE)
graphgen.PrintGraph(&gg)
}