Browse code

react to gonum/graph rebase

deads2k authored on 2015/07/17 03:02:26
Showing 15 changed files
... ...
@@ -94,16 +94,17 @@ type GraphDescriber interface {
94 94
 }
95 95
 
96 96
 type Interface interface {
97
-	graph.DirectedGraph
98
-	graph.EdgeLister
97
+	graph.Directed
99 98
 
100 99
 	GraphDescriber
101 100
 	MutableUniqueGraph
101
+
102
+	Edges() []graph.Edge
102 103
 }
103 104
 
104 105
 type Graph struct {
105 106
 	// the standard graph
106
-	graph.DirectedGraph
107
+	graph.Directed
107 108
 	// helper methods for switching on the kind and types of the node
108 109
 	GraphDescriber
109 110
 
... ...
@@ -120,7 +121,7 @@ var _ MutableUniqueGraph = Graph{}
120 120
 func New() Graph {
121 121
 	g := concrete.NewDirectedGraph()
122 122
 	return Graph{
123
-		DirectedGraph:  g,
123
+		Directed:       g,
124 124
 		GraphDescriber: typedGraph{},
125 125
 
126 126
 		uniqueNamedGraph: newUniqueNamedGraph(g),
... ...
@@ -129,19 +130,23 @@ func New() Graph {
129 129
 	}
130 130
 }
131 131
 
132
+func (g Graph) Edges() []graph.Edge {
133
+	return g.internal.Edges()
134
+}
135
+
132 136
 func (g Graph) String() string {
133 137
 	ret := ""
134 138
 
135
-	nodeList := g.NodeList()
136
-	sort.Sort(SortedNodeList(nodeList))
137
-	for _, node := range nodeList {
139
+	nodes := g.Nodes()
140
+	sort.Sort(SortedNodes(nodes))
141
+	for _, node := range nodes {
138 142
 		ret += fmt.Sprintf("%d: %v\n", node.ID(), g.GraphDescriber.Name(node))
139 143
 
140 144
 		// can't use SuccessorEdges, because I want stable ordering
141
-		successors := g.Successors(node)
142
-		sort.Sort(SortedNodeList(successors))
145
+		successors := g.From(node)
146
+		sort.Sort(SortedNodes(successors))
143 147
 		for _, successor := range successors {
144
-			edge := g.EdgeBetween(node, successor)
148
+			edge := g.Edge(node, successor)
145 149
 			kinds := g.EdgeKinds(edge)
146 150
 			for _, kind := range kinds.List() {
147 151
 				ret += fmt.Sprintf("\t%v to %d: %v\n", kind, successor.ID(), g.GraphDescriber.Name(successor))
... ...
@@ -152,11 +157,11 @@ func (g Graph) String() string {
152 152
 	return ret
153 153
 }
154 154
 
155
-type SortedNodeList []graph.Node
155
+type SortedNodes []graph.Node
156 156
 
157
-func (m SortedNodeList) Len() int      { return len(m) }
158
-func (m SortedNodeList) Swap(i, j int) { m[i], m[j] = m[j], m[i] }
159
-func (m SortedNodeList) Less(i, j int) bool {
157
+func (m SortedNodes) Len() int      { return len(m) }
158
+func (m SortedNodes) Swap(i, j int) { m[i], m[j] = m[j], m[i] }
159
+func (m SortedNodes) Less(i, j int) bool {
160 160
 	return m[i].ID() < m[j].ID()
161 161
 }
162 162
 
... ...
@@ -164,9 +169,9 @@ func (m SortedNodeList) Less(i, j int) bool {
164 164
 func (g Graph) SyntheticNodes() []graph.Node {
165 165
 	ret := []graph.Node{}
166 166
 
167
-	nodeList := g.NodeList()
168
-	sort.Sort(SortedNodeList(nodeList))
169
-	for _, node := range nodeList {
167
+	nodes := g.Nodes()
168
+	sort.Sort(SortedNodes(nodes))
169
+	for _, node := range nodes {
170 170
 		if potentiallySyntheticNode, ok := node.(ExistenceChecker); ok {
171 171
 			if !potentiallySyntheticNode.Found() {
172 172
 				ret = append(ret, node)
... ...
@@ -181,7 +186,7 @@ func (g Graph) NodesByKind(nodeKinds ...string) []graph.Node {
181 181
 	ret := []graph.Node{}
182 182
 
183 183
 	kinds := util.NewStringSet(nodeKinds...)
184
-	for _, node := range g.NodeList() {
184
+	for _, node := range g.internal.Nodes() {
185 185
 		if kinds.Has(g.Kind(node)) {
186 186
 			ret = append(ret, node)
187 187
 		}
... ...
@@ -193,8 +198,8 @@ func (g Graph) NodesByKind(nodeKinds ...string) []graph.Node {
193 193
 // RootNodes returns all the roots of this graph.
194 194
 func (g Graph) RootNodes() []graph.Node {
195 195
 	roots := []graph.Node{}
196
-	for _, n := range g.internal.NodeList() {
197
-		if len(g.internal.Predecessors(n)) != 0 {
196
+	for _, n := range g.Nodes() {
197
+		if len(g.To(n)) != 0 {
198 198
 			continue
199 199
 		}
200 200
 		roots = append(roots, n)
... ...
@@ -205,8 +210,8 @@ func (g Graph) RootNodes() []graph.Node {
205 205
 // PredecessorEdges invokes fn with all of the predecessor edges of node that have the specified
206 206
 // edge kind.
207 207
 func (g Graph) PredecessorEdges(node graph.Node, fn EdgeFunc, edgeKinds ...string) {
208
-	for _, n := range g.Predecessors(node) {
209
-		edge := g.EdgeBetween(n, node)
208
+	for _, n := range g.To(node) {
209
+		edge := g.Edge(n, node)
210 210
 		kinds := g.EdgeKinds(edge)
211 211
 
212 212
 		if kinds.HasAny(edgeKinds...) {
... ...
@@ -218,8 +223,8 @@ func (g Graph) PredecessorEdges(node graph.Node, fn EdgeFunc, edgeKinds ...strin
218 218
 // SuccessorEdges invokes fn with all of the successor edges of node that have the specified
219 219
 // edge kind.
220 220
 func (g Graph) SuccessorEdges(node graph.Node, fn EdgeFunc, edgeKinds ...string) {
221
-	for _, n := range g.Successors(node) {
222
-		edge := g.EdgeBetween(node, n)
221
+	for _, n := range g.From(node) {
222
+		edge := g.Edge(node, n)
223 223
 		kinds := g.EdgeKinds(edge)
224 224
 
225 225
 		if kinds.HasAny(edgeKinds...) {
... ...
@@ -233,8 +238,12 @@ func (g Graph) SuccessorEdges(node graph.Node, fn EdgeFunc, edgeKinds ...string)
233 233
 func (g Graph) OutboundEdges(node graph.Node, edgeKinds ...string) []graph.Edge {
234 234
 	ret := []graph.Edge{}
235 235
 
236
-	for _, n := range g.Successors(node) {
237
-		edge := g.EdgeBetween(n, node)
236
+	for _, n := range g.From(node) {
237
+		edge := g.Edge(node, n)
238
+		if edge == nil {
239
+			continue
240
+		}
241
+
238 242
 		if len(edgeKinds) == 0 || g.EdgeKinds(edge).HasAny(edgeKinds...) {
239 243
 			ret = append(ret, edge)
240 244
 		}
... ...
@@ -248,8 +257,12 @@ func (g Graph) OutboundEdges(node graph.Node, edgeKinds ...string) []graph.Edge
248 248
 func (g Graph) InboundEdges(node graph.Node, edgeKinds ...string) []graph.Edge {
249 249
 	ret := []graph.Edge{}
250 250
 
251
-	for _, n := range g.Predecessors(node) {
252
-		edge := g.EdgeBetween(n, node)
251
+	for _, n := range g.To(node) {
252
+		edge := g.Edge(n, node)
253
+		if edge == nil {
254
+			continue
255
+		}
256
+
253 257
 		if len(edgeKinds) == 0 || g.EdgeKinds(edge).HasAny(edgeKinds...) {
254 258
 			ret = append(ret, edge)
255 259
 		}
... ...
@@ -262,7 +275,7 @@ func (g Graph) PredecessorNodesByEdgeKind(node graph.Node, edgeKinds ...string)
262 262
 	ret := []graph.Node{}
263 263
 
264 264
 	for _, inboundEdges := range g.InboundEdges(node, edgeKinds...) {
265
-		ret = append(ret, inboundEdges.Head())
265
+		ret = append(ret, inboundEdges.From())
266 266
 	}
267 267
 
268 268
 	return ret
... ...
@@ -272,7 +285,7 @@ func (g Graph) SuccessorNodesByEdgeKind(node graph.Node, edgeKinds ...string) []
272 272
 	ret := []graph.Node{}
273 273
 
274 274
 	for _, outboundEdge := range g.OutboundEdges(node, edgeKinds...) {
275
-		ret = append(ret, outboundEdge.Tail())
275
+		ret = append(ret, outboundEdge.To())
276 276
 	}
277 277
 
278 278
 	return ret
... ...
@@ -292,10 +305,6 @@ func (g Graph) SuccessorNodesByNodeAndEdgeKind(node graph.Node, nodeKind, edgeKi
292 292
 	return ret
293 293
 }
294 294
 
295
-func (g Graph) EdgeList() []graph.Edge {
296
-	return g.internal.EdgeList()
297
-}
298
-
299 295
 func (g Graph) AddNode(n graph.Node) {
300 296
 	g.internal.AddNode(n)
301 297
 }
... ...
@@ -314,11 +323,11 @@ func (g Graph) AddEdge(head, tail graph.Node, edgeKind string) {
314 314
 	}
315 315
 
316 316
 	kinds := util.NewStringSet(edgeKind)
317
-	if existingEdge := g.EdgeBetween(head, tail); existingEdge != nil {
317
+	if existingEdge := g.Edge(head, tail); existingEdge != nil {
318 318
 		kinds.Insert(g.EdgeKinds(existingEdge).List()...)
319 319
 	}
320 320
 
321
-	g.internal.AddDirectedEdge(NewEdge(head, tail, kinds.List()...), 1)
321
+	g.internal.SetEdge(NewEdge(head, tail, kinds.List()...), 1)
322 322
 }
323 323
 
324 324
 // addEdges adds the specified edges, filtered by the provided edge connection
... ...
@@ -327,12 +336,12 @@ func (g Graph) addEdges(edges []graph.Edge, fn EdgeFunc) {
327 327
 	for _, e := range edges {
328 328
 		switch t := e.(type) {
329 329
 		case concrete.WeightedEdge:
330
-			if fn(g, t.Head(), t.Tail(), t.Edge.(Edge).Kinds()) {
331
-				g.internal.AddDirectedEdge(t.Edge.(Edge), t.Cost)
330
+			if fn(g, t.From(), t.To(), t.Edge.(Edge).Kinds()) {
331
+				g.internal.SetEdge(t.Edge.(Edge), t.Cost)
332 332
 			}
333 333
 		case Edge:
334
-			if fn(g, t.Head(), t.Tail(), t.Kinds()) {
335
-				g.internal.AddDirectedEdge(t, 1.0)
334
+			if fn(g, t.From(), t.To(), t.Kinds()) {
335
+				g.internal.SetEdge(t, 1.0)
336 336
 			}
337 337
 		default:
338 338
 			panic("bad edge")
... ...
@@ -352,10 +361,10 @@ type EdgeFunc func(g Interface, head, tail graph.Node, edgeKinds util.StringSet)
352 352
 // provided function.
353 353
 func (g Graph) EdgeSubgraph(edgeFn EdgeFunc) Graph {
354 354
 	out := New()
355
-	for _, node := range g.NodeList() {
355
+	for _, node := range g.Nodes() {
356 356
 		out.internal.AddNode(node)
357 357
 	}
358
-	out.addEdges(g.internal.EdgeList(), edgeFn)
358
+	out.addEdges(g.internal.Edges(), edgeFn)
359 359
 	return out
360 360
 }
361 361
 
... ...
@@ -363,12 +372,12 @@ func (g Graph) EdgeSubgraph(edgeFn EdgeFunc) Graph {
363 363
 // provided functions.
364 364
 func (g Graph) Subgraph(nodeFn NodeFunc, edgeFn EdgeFunc) Graph {
365 365
 	out := New()
366
-	for _, node := range g.NodeList() {
366
+	for _, node := range g.Nodes() {
367 367
 		if nodeFn(out, node) {
368 368
 			out.internal.AddNode(node)
369 369
 		}
370 370
 	}
371
-	out.addEdges(g.internal.EdgeList(), edgeFn)
371
+	out.addEdges(g.internal.Edges(), edgeFn)
372 372
 	return out
373 373
 }
374 374
 
... ...
@@ -379,7 +388,7 @@ func (g Graph) SubgraphWithNodes(nodes []graph.Node, fn EdgeFunc) Graph {
379 379
 	for _, node := range nodes {
380 380
 		out.internal.AddNode(node)
381 381
 	}
382
-	out.addEdges(g.internal.EdgeList(), fn)
382
+	out.addEdges(g.internal.Edges(), fn)
383 383
 	return out
384 384
 }
385 385
 
... ...
@@ -388,7 +397,7 @@ func (g Graph) SubgraphWithNodes(nodes []graph.Node, fn EdgeFunc) Graph {
388 388
 // an edge will be dropped unless the function adds them explicitly.
389 389
 func (g Graph) ConnectedEdgeSubgraph(fn EdgeFunc) Graph {
390 390
 	out := New()
391
-	out.addEdges(g.internal.EdgeList(), fn)
391
+	out.addEdges(g.internal.Edges(), fn)
392 392
 	return out
393 393
 }
394 394
 
... ...
@@ -401,7 +410,7 @@ func AllNodes(g Interface, node graph.Node) bool {
401 401
 // not ReferencedByEdgeKind (the generic reverse edge kind). This will purge the graph of any
402 402
 // edges created by AddReversedEdge.
403 403
 func ExistingDirectEdge(g Interface, head, tail graph.Node, edgeKinds util.StringSet) bool {
404
-	return !edgeKinds.Has(ReferencedByEdgeKind) && g.NodeExists(head) && g.NodeExists(tail)
404
+	return !edgeKinds.Has(ReferencedByEdgeKind) && g.Has(head) && g.Has(tail)
405 405
 }
406 406
 
407 407
 // ReverseExistingDirectEdge reverses the order of the edge and drops the existing edge only if
... ...
@@ -455,7 +464,7 @@ func (g uniqueNamedGraph) FindOrCreate(name UniqueName, fn NodeInitializerFunc)
455 455
 	if node, ok := g.names[name]; ok {
456 456
 		return node, true
457 457
 	}
458
-	id := g.NewNode().ID()
458
+	id := g.NewNodeID()
459 459
 	node := fn(Node{concrete.Node(id), name})
460 460
 	g.names[name] = node
461 461
 	g.AddNode(node)
... ...
@@ -540,7 +549,7 @@ func NodesByKind(g Interface, nodes []graph.Node, kinds ...string) [][]graph.Nod
540 540
 		buckets[kind] = i
541 541
 	}
542 542
 	if nodes == nil {
543
-		nodes = g.NodeList()
543
+		nodes = g.Nodes()
544 544
 	}
545 545
 
546 546
 	last := len(kinds)
... ...
@@ -578,12 +587,12 @@ func pathEqual(a, b []graph.Node) bool {
578 578
 }
579 579
 
580 580
 func Fprint(out io.Writer, g Graph) {
581
-	for _, node := range g.NodeList() {
581
+	for _, node := range g.Nodes() {
582 582
 		fmt.Fprintf(out, "node %d %s\n", node.ID(), node)
583 583
 	}
584
-	for _, edge := range g.EdgeList() {
584
+	for _, edge := range g.Edges() {
585 585
 		for _, edgeKind := range g.EdgeKinds(edge).List() {
586
-			fmt.Fprintf(out, "edge %d -> %d : %d\n", edge.Head().ID(), edge.Head().ID(), edgeKind)
586
+			fmt.Fprintf(out, "edge %d -> %d : %d\n", edge.From().ID(), edge.From().ID(), edgeKind)
587 587
 		}
588 588
 	}
589 589
 }
... ...
@@ -13,7 +13,7 @@ func TestMultipleEdgeKindsBetweenTheSameNodes(t *testing.T) {
13 13
 	g.AddEdge(fooNode, barNode, "first")
14 14
 	g.AddEdge(fooNode, barNode, "second")
15 15
 
16
-	edge := g.EdgeBetween(fooNode, barNode)
16
+	edge := g.Edge(fooNode, barNode)
17 17
 	if !g.EdgeKinds(edge).Has("first") {
18 18
 		t.Errorf("expected first, got %v", edge)
19 19
 	}
... ...
@@ -330,7 +330,7 @@ func TestGraph(t *testing.T) {
330 330
 
331 331
 	t.Log(g)
332 332
 
333
-	for _, edge := range g.EdgeList() {
333
+	for _, edge := range g.Edges() {
334 334
 		if g.EdgeKinds(edge).Has(osgraph.UnknownEdgeKind) {
335 335
 			t.Errorf("edge reported unknown kind: %#v", edge)
336 336
 		}
... ...
@@ -338,28 +338,25 @@ func TestGraph(t *testing.T) {
338 338
 
339 339
 	// imagestreamtag default/other:base-image
340 340
 	istID := 0
341
-	for _, node := range g.NodeList() {
341
+	for _, node := range g.Nodes() {
342 342
 		if g.Name(node) == "ImageStreamTag|default/other:base-image" {
343 343
 			istID = node.ID()
344 344
 			break
345 345
 		}
346 346
 	}
347 347
 
348
-	edge := g.EdgeBetween(concrete.Node(bcTestNode.ID()), concrete.Node(istID))
348
+	edge := g.Edge(concrete.Node(bcTestNode.ID()), concrete.Node(istID))
349 349
 	if edge == nil {
350 350
 		t.Fatalf("failed to find edge between %d and %d", bcTestNode.ID(), istID)
351 351
 	}
352
-	if len(g.SubgraphWithNodes([]graph.Node{edge.Head(), edge.Tail()}, osgraph.ExistingDirectEdge).EdgeList()) != 1 {
352
+	if len(g.SubgraphWithNodes([]graph.Node{edge.From(), edge.To()}, osgraph.ExistingDirectEdge).Edges()) != 1 {
353 353
 		t.Fatalf("expected one edge")
354 354
 	}
355
-	if len(g.SubgraphWithNodes([]graph.Node{edge.Tail(), edge.Head()}, osgraph.ExistingDirectEdge).EdgeList()) != 1 {
355
+	if len(g.SubgraphWithNodes([]graph.Node{edge.To(), edge.From()}, osgraph.ExistingDirectEdge).Edges()) != 1 {
356 356
 		t.Fatalf("expected one edge")
357 357
 	}
358 358
 
359
-	if e := g.EdgeBetween(concrete.Node(bcTestNode.ID()), concrete.Node(istID)); e == nil {
360
-		t.Errorf("expected edge for %d-%d", bcTestNode.ID(), istID)
361
-	}
362
-	if e := g.EdgeBetween(concrete.Node(istID), concrete.Node(bcTestNode.ID())); e == nil {
359
+	if e := g.Edge(concrete.Node(bcTestNode.ID()), concrete.Node(istID)); e == nil {
363 360
 		t.Errorf("expected edge for %d-%d", bcTestNode.ID(), istID)
364 361
 	}
365 362
 
... ...
@@ -61,8 +61,8 @@ func GetTopLevelContainerNode(g Graph, containedNode graph.Node) graph.Node {
61 61
 // GetContainingNode returns the direct predecessor that is linked to the node by a ContainsEdgeKind.  It returns
62 62
 // nil if no container is found.
63 63
 func GetContainingNode(g Graph, containedNode graph.Node) graph.Node {
64
-	for _, node := range g.Predecessors(containedNode) {
65
-		edge := g.EdgeBetween(node, containedNode)
64
+	for _, node := range g.To(containedNode) {
65
+		edge := g.Edge(node, containedNode)
66 66
 
67 67
 		if g.EdgeKinds(edge).Has(ContainsEdgeKind) {
68 68
 			return node
... ...
@@ -41,6 +41,10 @@ func TestContainsNavigation(t *testing.T) {
41 41
 	}
42 42
 
43 43
 	containsB := GetContainingNode(g, bNode)
44
+	if containsB == nil {
45
+		t.Fatal(g)
46
+	}
47
+
44 48
 	if e, a := aNode.ID(), containsB.ID(); e != a {
45 49
 		t.Errorf("expected %v, got %v", e, a)
46 50
 	}
... ...
@@ -32,7 +32,7 @@ func TestSecretEdges(t *testing.T) {
32 32
 	AddAllMountableSecretEdges(g)
33 33
 	AddAllMountedSecretEdges(g)
34 34
 
35
-	if edge := g.EdgeBetween(saNode, secretNode); edge == nil {
35
+	if edge := g.Edge(saNode, secretNode); edge == nil {
36 36
 		t.Errorf("edge missing")
37 37
 	} else {
38 38
 		if !g.EdgeKinds(edge).Has(MountableSecretEdgeKind) {
... ...
@@ -45,7 +45,7 @@ func TestSecretEdges(t *testing.T) {
45 45
 		t.Fatalf("wrong number of podspecs: %v", podSpecNodes)
46 46
 	}
47 47
 
48
-	if edge := g.EdgeBetween(podSpecNodes[0], secretNode); edge == nil {
48
+	if edge := g.Edge(podSpecNodes[0], secretNode); edge == nil {
49 49
 		t.Errorf("edge missing")
50 50
 	} else {
51 51
 		if !g.EdgeKinds(edge).Has(MountedSecretEdgeKind) {
... ...
@@ -31,7 +31,7 @@ func AddExposedPodTemplateSpecEdges(g osgraph.MutableUniqueGraph, node *kubegrap
31 31
 		return
32 32
 	}
33 33
 	query := labels.SelectorFromSet(node.Service.Spec.Selector)
34
-	for _, n := range g.(graph.Graph).NodeList() {
34
+	for _, n := range g.(graph.Graph).Nodes() {
35 35
 		switch target := n.(type) {
36 36
 		case *kubegraph.PodTemplateSpecNode:
37 37
 			if query.Matches(labels.Set(target.PodTemplateSpec.Labels)) {
... ...
@@ -43,7 +43,7 @@ func AddExposedPodTemplateSpecEdges(g osgraph.MutableUniqueGraph, node *kubegrap
43 43
 
44 44
 // AddAllExposedPodTemplateSpecEdges calls AddExposedPodTemplateSpecEdges for every ServiceNode in the graph
45 45
 func AddAllExposedPodTemplateSpecEdges(g osgraph.MutableUniqueGraph) {
46
-	for _, node := range g.(graph.Graph).NodeList() {
46
+	for _, node := range g.(graph.Graph).Nodes() {
47 47
 		if serviceNode, ok := node.(*kubegraph.ServiceNode); ok {
48 48
 			AddExposedPodTemplateSpecEdges(g, serviceNode)
49 49
 		}
... ...
@@ -57,7 +57,7 @@ func AddExposedPodEdges(g osgraph.MutableUniqueGraph, node *kubegraph.ServiceNod
57 57
 		return
58 58
 	}
59 59
 	query := labels.SelectorFromSet(node.Service.Spec.Selector)
60
-	for _, n := range g.(graph.Graph).NodeList() {
60
+	for _, n := range g.(graph.Graph).Nodes() {
61 61
 		switch target := n.(type) {
62 62
 		case *kubegraph.PodNode:
63 63
 			if query.Matches(labels.Set(target.Labels)) {
... ...
@@ -69,7 +69,7 @@ func AddExposedPodEdges(g osgraph.MutableUniqueGraph, node *kubegraph.ServiceNod
69 69
 
70 70
 // AddAllExposedPodEdges calls AddExposedPodEdges for every ServiceNode in the graph
71 71
 func AddAllExposedPodEdges(g osgraph.MutableUniqueGraph) {
72
-	for _, node := range g.(graph.Graph).NodeList() {
72
+	for _, node := range g.(graph.Graph).Nodes() {
73 73
 		if serviceNode, ok := node.(*kubegraph.ServiceNode); ok {
74 74
 			AddExposedPodEdges(g, serviceNode)
75 75
 		}
... ...
@@ -83,7 +83,7 @@ func AddManagedByRCPodEdges(g osgraph.MutableUniqueGraph, rcNode *kubegraph.Repl
83 83
 		return
84 84
 	}
85 85
 	query := labels.SelectorFromSet(rcNode.Spec.Selector)
86
-	for _, n := range g.(graph.Graph).NodeList() {
86
+	for _, n := range g.(graph.Graph).Nodes() {
87 87
 		switch target := n.(type) {
88 88
 		case *kubegraph.PodNode:
89 89
 			if query.Matches(labels.Set(target.Labels)) {
... ...
@@ -95,7 +95,7 @@ func AddManagedByRCPodEdges(g osgraph.MutableUniqueGraph, rcNode *kubegraph.Repl
95 95
 
96 96
 // AddAllManagedByRCPodEdges calls AddManagedByRCPodEdges for every ServiceNode in the graph
97 97
 func AddAllManagedByRCPodEdges(g osgraph.MutableUniqueGraph) {
98
-	for _, node := range g.(graph.Graph).NodeList() {
98
+	for _, node := range g.(graph.Graph).Nodes() {
99 99
 		if rcNode, ok := node.(*kubegraph.ReplicationControllerNode); ok {
100 100
 			AddManagedByRCPodEdges(g, rcNode)
101 101
 		}
... ...
@@ -130,7 +130,7 @@ func AddMountedSecretEdges(g osgraph.Graph, podSpec *kubegraph.PodSpecNode) {
130 130
 }
131 131
 
132 132
 func AddAllMountedSecretEdges(g osgraph.Graph) {
133
-	for _, node := range g.NodeList() {
133
+	for _, node := range g.Nodes() {
134 134
 		if podSpecNode, ok := node.(*kubegraph.PodSpecNode); ok {
135 135
 			AddMountedSecretEdges(g, podSpecNode)
136 136
 		}
... ...
@@ -149,7 +149,7 @@ func AddMountableSecretEdges(g osgraph.Graph, saNode *kubegraph.ServiceAccountNo
149 149
 }
150 150
 
151 151
 func AddAllMountableSecretEdges(g osgraph.Graph) {
152
-	for _, node := range g.NodeList() {
152
+	for _, node := range g.Nodes() {
153 153
 		if saNode, ok := node.(*kubegraph.ServiceAccountNode); ok {
154 154
 			AddMountableSecretEdges(g, saNode)
155 155
 		}
... ...
@@ -181,7 +181,7 @@ func AddRequestedServiceAccountEdges(g osgraph.Graph, podSpecNode *kubegraph.Pod
181 181
 }
182 182
 
183 183
 func AddAllRequestedServiceAccountEdges(g osgraph.Graph) {
184
-	for _, node := range g.NodeList() {
184
+	for _, node := range g.Nodes() {
185 185
 		if podSpecNode, ok := node.(*kubegraph.PodSpecNode); ok {
186 186
 			AddRequestedServiceAccountEdges(g, podSpecNode)
187 187
 		}
... ...
@@ -18,20 +18,20 @@ func TestPodSpecNode(t *testing.T) {
18 18
 
19 19
 	podNode := EnsurePodNode(g, pod)
20 20
 
21
-	if len(g.NodeList()) != 2 {
22
-		t.Errorf("expected 2 nodes, got %v", g.NodeList())
21
+	if len(g.Nodes()) != 2 {
22
+		t.Errorf("expected 2 nodes, got %v", g.Nodes())
23 23
 	}
24 24
 
25
-	if len(g.EdgeList()) != 1 {
26
-		t.Errorf("expected 1 edge, got %v", g.EdgeList())
25
+	if len(g.Edges()) != 1 {
26
+		t.Errorf("expected 1 edge, got %v", g.Edges())
27 27
 	}
28 28
 
29
-	edge := g.EdgeList()[0]
29
+	edge := g.Edges()[0]
30 30
 	if !g.EdgeKinds(edge).Has(osgraph.ContainsEdgeKind) {
31 31
 		t.Errorf("expected %v, got %v", osgraph.ContainsEdgeKind, g.EdgeKinds(edge))
32 32
 	}
33
-	if edge.Head().ID() != podNode.ID() {
34
-		t.Errorf("expected %v, got %v", podNode.ID(), edge.Head())
33
+	if edge.From().ID() != podNode.ID() {
34
+		t.Errorf("expected %v, got %v", podNode.ID(), edge.From())
35 35
 	}
36 36
 }
37 37
 
... ...
@@ -45,23 +45,23 @@ func TestReplicationControllerSpecNode(t *testing.T) {
45 45
 
46 46
 	rcNode := EnsureReplicationControllerNode(g, rc)
47 47
 
48
-	if len(g.NodeList()) != 4 {
49
-		t.Errorf("expected 4 nodes, got %v", g.NodeList())
48
+	if len(g.Nodes()) != 4 {
49
+		t.Errorf("expected 4 nodes, got %v", g.Nodes())
50 50
 	}
51 51
 
52
-	if len(g.EdgeList()) != 3 {
53
-		t.Errorf("expected 3 edge, got %v", g.EdgeList())
52
+	if len(g.Edges()) != 3 {
53
+		t.Errorf("expected 3 edge, got %v", g.Edges())
54 54
 	}
55 55
 
56 56
 	rcEdges := g.OutboundEdges(rcNode)
57 57
 	if len(rcEdges) != 1 {
58
-		t.Fatalf("expected 1 edge, got %v", rcEdges)
58
+		t.Fatalf("expected 1 edge, got %v for \n%v", rcEdges, g)
59 59
 	}
60 60
 	if !g.EdgeKinds(rcEdges[0]).Has(osgraph.ContainsEdgeKind) {
61 61
 		t.Errorf("expected %v, got %v", osgraph.ContainsEdgeKind, rcEdges[0])
62 62
 	}
63 63
 
64
-	uncastRCSpec := rcEdges[0].Tail()
64
+	uncastRCSpec := rcEdges[0].To()
65 65
 	rcSpec, ok := uncastRCSpec.(*ReplicationControllerSpecNode)
66 66
 	if !ok {
67 67
 		t.Fatalf("expected rcSpec, got %v", uncastRCSpec)
... ...
@@ -74,7 +74,7 @@ func TestReplicationControllerSpecNode(t *testing.T) {
74 74
 		t.Errorf("expected %v, got %v", osgraph.ContainsEdgeKind, rcSpecEdges[0])
75 75
 	}
76 76
 
77
-	uncastPTSpec := rcSpecEdges[0].Tail()
77
+	uncastPTSpec := rcSpecEdges[0].To()
78 78
 	ptSpec, ok := uncastPTSpec.(*PodTemplateSpecNode)
79 79
 	if !ok {
80 80
 		t.Fatalf("expected ptspec, got %v", uncastPTSpec)
... ...
@@ -20,7 +20,7 @@ const (
20 20
 )
21 21
 
22 22
 func AddBuildEdges(g osgraph.MutableUniqueGraph, node *buildgraph.BuildConfigNode) {
23
-	for _, n := range g.(graph.Graph).NodeList() {
23
+	for _, n := range g.(graph.Graph).Nodes() {
24 24
 		if buildNode, ok := n.(*buildgraph.BuildNode); ok {
25 25
 			if belongsToBuildConfig(node.BuildConfig, buildNode.Build) {
26 26
 				g.AddEdge(node, buildNode, BuildEdgeKind)
... ...
@@ -30,7 +30,7 @@ func AddBuildEdges(g osgraph.MutableUniqueGraph, node *buildgraph.BuildConfigNod
30 30
 }
31 31
 
32 32
 func AddAllBuildEdges(g osgraph.MutableUniqueGraph) {
33
-	for _, node := range g.(graph.Graph).NodeList() {
33
+	for _, node := range g.(graph.Graph).Nodes() {
34 34
 		if bcNode, ok := node.(*buildgraph.BuildConfigNode); ok {
35 35
 			AddBuildEdges(g, bcNode)
36 36
 		}
... ...
@@ -80,7 +80,7 @@ func AddInputOutputEdges(g osgraph.MutableUniqueGraph, node *buildgraph.BuildCon
80 80
 }
81 81
 
82 82
 func AddAllInputOutputEdges(g osgraph.MutableUniqueGraph) {
83
-	for _, node := range g.(graph.Graph).NodeList() {
83
+	for _, node := range g.(graph.Graph).Nodes() {
84 84
 		if bcNode, ok := node.(*buildgraph.BuildConfigNode); ok {
85 85
 			AddInputOutputEdges(g, bcNode)
86 86
 		}
... ...
@@ -133,7 +133,7 @@ func (d *ProjectStatusDescriber) Describe(namespace, name string) (string, error
133 133
 			for _, podNode := range service.FulfillingPods {
134 134
 				// skip pods that have been displayed in a roll-up of RCs and DCs (by implicit usage of RCs)
135 135
 				for _, coveredRC := range service.FulfillingRCs {
136
-					if g.EdgeBetween(podNode, coveredRC) != nil {
136
+					if g.Edge(podNode, coveredRC) != nil {
137 137
 						continue pod
138 138
 					}
139 139
 				}
... ...
@@ -22,8 +22,8 @@ func DescendentNodesByNodeKind(g osgraph.Graph, visitedNodes graphview.IntSet, n
22 22
 	visitedNodes.Insert(node.ID())
23 23
 
24 24
 	ret := []graph.Node{}
25
-	for _, successor := range g.Successors(node) {
26
-		edge := g.EdgeBetween(node, successor)
25
+	for _, successor := range g.From(node) {
26
+		edge := g.Edge(node, successor)
27 27
 
28 28
 		if edgeChecker(osgraph.New(), node, successor, g.EdgeKinds(edge)) {
29 29
 			if g.Kind(successor) == targetNodeKind {
... ...
@@ -49,7 +49,7 @@ func AddTriggerEdges(g osgraph.MutableUniqueGraph, node *deploygraph.DeploymentC
49 49
 }
50 50
 
51 51
 func AddAllTriggerEdges(g osgraph.MutableUniqueGraph) {
52
-	for _, node := range g.(graph.Graph).NodeList() {
52
+	for _, node := range g.(graph.Graph).Nodes() {
53 53
 		if dcNode, ok := node.(*deploygraph.DeploymentConfigNode); ok {
54 54
 			AddTriggerEdges(g, dcNode)
55 55
 		}
... ...
@@ -57,7 +57,7 @@ func AddAllTriggerEdges(g osgraph.MutableUniqueGraph) {
57 57
 }
58 58
 
59 59
 func AddDeploymentEdges(g osgraph.MutableUniqueGraph, node *deploygraph.DeploymentConfigNode) *deploygraph.DeploymentConfigNode {
60
-	for _, n := range g.(graph.Graph).NodeList() {
60
+	for _, n := range g.(graph.Graph).Nodes() {
61 61
 		if rcNode, ok := n.(*kubegraph.ReplicationControllerNode); ok {
62 62
 			if BelongsToDeploymentConfig(node.DeploymentConfig, rcNode.ReplicationController) {
63 63
 				g.AddEdge(node, rcNode, DeploymentEdgeKind)
... ...
@@ -69,7 +69,7 @@ func AddDeploymentEdges(g osgraph.MutableUniqueGraph, node *deploygraph.Deployme
69 69
 }
70 70
 
71 71
 func AddAllDeploymentEdges(g osgraph.MutableUniqueGraph) {
72
-	for _, node := range g.(graph.Graph).NodeList() {
72
+	for _, node := range g.(graph.Graph).Nodes() {
73 73
 		if dcNode, ok := node.(*deploygraph.DeploymentConfigNode); ok {
74 74
 			AddDeploymentEdges(g, dcNode)
75 75
 		}
... ...
@@ -16,19 +16,19 @@ func TestDCRCSpecNode(t *testing.T) {
16 16
 
17 17
 	dcNode := EnsureDeploymentConfigNode(g, dc)
18 18
 
19
-	if len(g.NodeList()) != 2 {
20
-		t.Errorf("expected 2 nodes, got %v", g.NodeList())
19
+	if len(g.Nodes()) != 2 {
20
+		t.Errorf("expected 2 nodes, got %v", g.Nodes())
21 21
 	}
22 22
 
23
-	if len(g.EdgeList()) != 1 {
24
-		t.Errorf("expected 2 edge, got %v", g.EdgeList())
23
+	if len(g.Edges()) != 1 {
24
+		t.Errorf("expected 2 edge, got %v", g.Edges())
25 25
 	}
26 26
 
27
-	edge := g.EdgeList()[0]
27
+	edge := g.Edges()[0]
28 28
 	if !g.EdgeKinds(edge).Has(osgraph.ContainsEdgeKind) {
29 29
 		t.Errorf("expected %v, got %v", osgraph.ContainsEdgeKind, g.EdgeKinds(edge))
30 30
 	}
31
-	if edge.Head().ID() != dcNode.ID() {
32
-		t.Errorf("expected %v, got %v", dcNode.ID(), edge.Head())
31
+	if edge.From().ID() != dcNode.ID() {
32
+		t.Errorf("expected %v, got %v", dcNode.ID(), edge.From())
33 33
 	}
34 34
 }
... ...
@@ -26,7 +26,7 @@ func AddImageStreamRefEdge(g osgraph.MutableUniqueGraph, node *imagegraph.ImageS
26 26
 
27 27
 // AddAllImageStreamRefEdges calls AddImageStreamRefEdge for every ImageStreamTagNode in the graph
28 28
 func AddAllImageStreamRefEdges(g osgraph.MutableUniqueGraph) {
29
-	for _, node := range g.(graph.Graph).NodeList() {
29
+	for _, node := range g.(graph.Graph).Nodes() {
30 30
 		if istNode, ok := node.(*imagegraph.ImageStreamTagNode); ok {
31 31
 			AddImageStreamRefEdge(g, istNode)
32 32
 		}
... ...
@@ -350,7 +350,7 @@ func addImageStreamsToGraph(g graph.Graph, streams *imageapi.ImageStreamList, al
350 350
 				}
351 351
 
352 352
 				glog.V(4).Infof("Checking for existing strong reference from stream %s/%s to image %s", stream.Namespace, stream.Name, imageNode.Image.Name)
353
-				if edge := g.EdgeBetween(imageStreamNode, imageNode); edge != nil && g.EdgeKinds(edge).Has(ReferencedImageEdgeKind) {
353
+				if edge := g.Edge(imageStreamNode, imageNode); edge != nil && g.EdgeKinds(edge).Has(ReferencedImageEdgeKind) {
354 354
 					glog.V(4).Infof("Strong reference found")
355 355
 					continue
356 356
 				}
... ...
@@ -360,7 +360,7 @@ func addImageStreamsToGraph(g graph.Graph, streams *imageapi.ImageStreamList, al
360 360
 
361 361
 				glog.V(4).Infof("Adding stream->layer references")
362 362
 				// add stream -> layer references so we can prune them later
363
-				for _, s := range g.Successors(imageNode) {
363
+				for _, s := range g.From(imageNode) {
364 364
 					if g.Kind(s) != imagegraph.ImageLayerNodeKind {
365 365
 						continue
366 366
 					}
... ...
@@ -547,7 +547,7 @@ func getImageNodes(nodes []gonum.Node) []*imagegraph.ImageNode {
547 547
 
548 548
 // edgeKind returns true if the edge from "from" to "to" is of the desired kind.
549 549
 func edgeKind(g graph.Graph, from, to gonum.Node, desiredKind string) bool {
550
-	edge := g.EdgeBetween(from, to)
550
+	edge := g.Edge(from, to)
551 551
 	kinds := g.EdgeKinds(edge)
552 552
 	return kinds.Has(desiredKind)
553 553
 }
... ...
@@ -560,7 +560,7 @@ func edgeKind(g graph.Graph, from, to gonum.Node, desiredKind string) bool {
560 560
 func imageIsPrunable(g graph.Graph, imageNode *imagegraph.ImageNode) bool {
561 561
 	onlyWeakReferences := true
562 562
 
563
-	for _, n := range g.Predecessors(imageNode) {
563
+	for _, n := range g.To(imageNode) {
564 564
 		glog.V(4).Infof("Examining predecessor %#v", n)
565 565
 		if !edgeKind(g, n, imageNode, WeakReferencedImageEdgeKind) {
566 566
 			glog.V(4).Infof("Strong reference detected")
... ...
@@ -615,7 +615,7 @@ func subgraphWithoutPrunableImages(g graph.Graph, prunableImageIDs graph.NodeSet
615 615
 func calculatePrunableLayers(g graph.Graph) []*imagegraph.ImageLayerNode {
616 616
 	prunable := []*imagegraph.ImageLayerNode{}
617 617
 
618
-	nodes := g.NodeList()
618
+	nodes := g.Nodes()
619 619
 	for i := range nodes {
620 620
 		layerNode, ok := nodes[i].(*imagegraph.ImageLayerNode)
621 621
 		if !ok {
... ...
@@ -641,7 +641,7 @@ func pruneStreams(g graph.Graph, imageNodes []*imagegraph.ImageNode, streamPrune
641 641
 
642 642
 	glog.V(4).Infof("Removing pruned image references from streams")
643 643
 	for _, imageNode := range imageNodes {
644
-		for _, n := range g.Predecessors(imageNode) {
644
+		for _, n := range g.To(imageNode) {
645 645
 			streamNode, ok := n.(*imagegraph.ImageStreamNode)
646 646
 			if !ok {
647 647
 				continue
... ...
@@ -722,7 +722,7 @@ func (p *imageRegistryPruner) determineRegistry(imageNodes []*imagegraph.ImageNo
722 722
 // image, and then it identifies layers eligible for pruning, invoking
723 723
 // layerPruneFunc for each registry URL that has layers that can be pruned.
724 724
 func (p *imageRegistryPruner) Prune(imagePruner ImagePruner, streamPruner ImageStreamPruner, layerPruner LayerPruner, blobPruner BlobPruner, manifestPruner ManifestPruner) error {
725
-	allNodes := p.g.NodeList()
725
+	allNodes := p.g.Nodes()
726 726
 
727 727
 	imageNodes := getImageNodes(allNodes)
728 728
 	if len(imageNodes) == 0 {
... ...
@@ -763,7 +763,7 @@ func (p *imageRegistryPruner) Prune(imagePruner ImagePruner, streamPruner ImageS
763 763
 
764 764
 // layerIsPrunable returns true if the layer is not referenced by any images.
765 765
 func layerIsPrunable(g graph.Graph, layerNode *imagegraph.ImageLayerNode) bool {
766
-	for _, predecessor := range g.Predecessors(layerNode) {
766
+	for _, predecessor := range g.To(layerNode) {
767 767
 		glog.V(4).Infof("Examining layer predecessor %#v", predecessor)
768 768
 		if g.Kind(predecessor) == imagegraph.ImageNodeKind {
769 769
 			glog.V(4).Infof("Layer has an image predecessor")
... ...
@@ -779,7 +779,7 @@ func layerIsPrunable(g graph.Graph, layerNode *imagegraph.ImageLayerNode) bool {
779 779
 func streamLayerReferences(g graph.Graph, layerNode *imagegraph.ImageLayerNode) []*imagegraph.ImageStreamNode {
780 780
 	ret := []*imagegraph.ImageStreamNode{}
781 781
 
782
-	for _, predecessor := range g.Predecessors(layerNode) {
782
+	for _, predecessor := range g.To(layerNode) {
783 783
 		if g.Kind(predecessor) != imagegraph.ImageStreamNodeKind {
784 784
 			continue
785 785
 		}
... ...
@@ -834,7 +834,7 @@ func pruneManifests(g graph.Graph, registryClient *http.Client, registryURL stri
834 834
 	errs := []error{}
835 835
 
836 836
 	for _, imageNode := range imageNodes {
837
-		for _, n := range g.Predecessors(imageNode) {
837
+		for _, n := range g.To(imageNode) {
838 838
 			streamNode, ok := n.(*imagegraph.ImageStreamNode)
839 839
 			if !ok {
840 840
 				continue