Esempio n. 1
0
 def __iter__(self):
     cur = gv.firstedge(self.parent.handle)
     while gv.ok(cur):
         yield (decode_page(gv.nameof(gv.tailof(cur))), 
                decode_page(gv.nameof(gv.headof(cur)))), \
                dict(self.graph._iterattrs(cur))
         cur = gv.nextedge(self.parent.handle, cur)
Esempio n. 2
0
    def generate(self, filename):
        '''
        Displays the graph on the canvas
        Uses python-igraph fruchterman-reingold algorithm to decide about
        position of the nodes, then draw these nodes on the canvas and
        draw connections between them
        Author: Jan Vorcak <*****@*****.**>
        '''

        g = gv.readstring(self.source)
        gv.layout(g, 'dot')
        gv.render(g)

        context = CanvasContext().dictionary

        node = gv.firstnode(g)
        while node is not None:
            props = {
                    'filepath' : gv.getv(node, 'filepath'),
                    'title' : gv.getv(node, 'label'),
                    'lineno' : gv.getv(node, 'lineno'),
                    }
            pos = gv.getv(node, 'pos').split(',')
            width = gv.getv(node, 'width')
            height = gv.getv(node, 'height')
            x, y = map(int, pos)
            class_box = ClassBox(props, width, height)
            class_box.matrix.translate(x, y)
            self.view.canvas.add(class_box)
            context[(props['filepath'], props['title'])] = class_box
            node = gv.nextnode(g, node)

        edge = gv.firstedge(g)
        while edge is not None:
            props = {
                    'arrowhead' : gv.getv(edge, 'arrowhead'),
                    'arrowtail' : gv.getv(edge, 'arrowtail'),
                    }

            head = gv.headof(edge)
            tail = gv.tailof(edge)
            head_str = (gv.getv(head, 'filepath'), gv.getv(head, 'label'))
            tail_str = (gv.getv(tail, 'filepath'), gv.getv(tail, 'label'))
            context[head_str]
            context[tail_str]

            edge = gv.nextedge(g, edge)
            set_association(self.view.canvas, context[head_str], \
                    context[tail_str], props)
Esempio n. 3
0
def get_edge_list(graph_h):
    """Generator to iterate over all edges of a graph"""
    handle = gv.firstedge(graph_h)
    while gv.ok(handle):
        yield handle
        handle = gv.nextedge(graph_h, handle)
def get_edge_list(graph_h):
    """Generator to iterate over all edges of a graph"""
    handle = gv.firstedge(graph_h)
    while gv.ok(handle):
        yield handle
        handle = gv.nextedge(graph_h, handle)