MCPcopy Create free account
hub / github.com/ActiveState/code / update

Method update

recipes/Python/578615_graph/recipe-578615.py:382–393  ·  view source on GitHub ↗

Merges one graph with another. All vertices will be convertex to VertexType. Takes union of edge lists. >>> g1, g2 = Graph(VertexType=Vertex), Graph(VertexType=WVertex) >>> g1.add(1, [1, 2]) >>> g2.add(3, [2, 3]); g2.add(1, 2, 3); g2.add(1, 4, 2) >>> g1.update(g2)

(self, other, default=USE_DEFAULT, collision=MERGE_VERTEX)

Source from the content-addressed store, hash-verified

380 super(Graph, self).__init__(init, {}, MERGE_VERTEX)
381
382 def update(self, other, default=USE_DEFAULT, collision=MERGE_VERTEX): #XXX could remove this if collision was attribute of defdict
383 """Merges one graph with another. All vertices will be convertex to VertexType. Takes union of edge lists.
384 >>> g1, g2 = Graph(VertexType=Vertex), Graph(VertexType=WVertex)
385 >>> g1.add(1, [1, 2])
386 >>> g2.add(3, [2, 3]); g2.add(1, 2, 3); g2.add(1, 4, 2)
387 >>> g1.update(g2) #XXX weight values get set on plain Vertex.
388 >>> print g1
389 {1: {1, 2, 4}, 2: {}, 3: {2, 3}, 4: {}}
390 >>> g2.add(3, 5) #changes to g2 should not affect g1
391 >>> g1._validate()
392 """
393 super(Graph, self).update(other, default, collision)
394
395 def add(self, head, tail=[], edge_value=VertexCommon.EDGEVALUE):
396 """Add the vertices and/or edges.

Callers 15

mandelFunction · 0.45
cloneMethod · 0.45
game_introFunction · 0.45
pauseFunction · 0.45
gameLoopFunction · 0.45
getEpsFunction · 0.45
recipe-578965.pyFile · 0.45
funcFunction · 0.45
dfsFunction · 0.45
new_decoratorFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected