def AddEdgeByVertices(self, tail, head): try: SubGraph.AddEdge(self, tail, head) self.Animator.SetEdgeColor(tail, head, self.Color) self.Animator.DefaultInfo() except NoSuchVertexError, NoSuchEdgeError: return
def AddVertex(self, v): try: SubGraph.AddVertex(self, v) self.Animator.SetVertexColor(v, self.Color) self.Animator.DefaultInfo() except NoSuchVertexError: return
def AddSubGraph(self, G): """ Add subgraph G to self. Will do nothing if self and G have distinct supergraphs """ if self.superGraph != G.superGraph: log.error("AddSubGraph: distinct superGraphs") return for v in G.Vertices(): if G.QIsolated(v): SubGraph.AddVertex(self, v) for t, h in G.Edges(): SubGraph.AddEdge(self, t, h) self.Animator.SetEdgesColor(G.Edges(), self.Color) #print "Just called setEdgesColor animator is ", self.Animator.__class__.__name__ self.Animator.SetAllVerticesColor(self.Color, graph=G) self.RaiseEdges() self.Animator.DefaultInfo()
def DeleteEdge(self, edge, head=None): if head == None and len(edge) == 2: t = edge[0] h = edge[1] else: t = edge h = head try: SubGraph.DeleteEdge(self, t, h) self.Animator.SetEdgeColor(t, h, "black") except NoSuchVertexError, NoSuchEdgeError: return
def AddEdge(self, edge, head=None): # Poor mans function overload if head == None and len(edge) == 2: t = edge[0] h = edge[1] else: t = edge h = head try: SubGraph.AddEdge(self, t, h) self.Animator.SetEdgeColor(t, h, self.Color) # Raise edges above other tt, hh = self.superGraph.Edge(t, h) self.Animator.RaiseEdge(tt, hh) self.Animator.DefaultInfo() except NoSuchVertexError, NoSuchEdgeError: return
def __init__(self, G, theAnimator, color="blue"): """ color is used to color vertices and edges in the subgraph. theAnimator will usually be the GraphDisplay(Frame/Toplevel) """ SubGraph.__init__(self, G) self.Animator = theAnimator self.Color = color