How to use the pydot.pydot.Edge function in pydot

To help you get started, we’ve selected a few pydot examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github markflorisson / minivect / graphviz.py View on Github external
def add_edge(self, source, dest, edge_label=None):
        "Add an edge between two pydot nodes and set the colors"
        edge = pydot.Edge(source, dest)

        if edge_label is not None:
            edge.set_label(edge_label)
        if self.edge_color is not None:
            edge.set_color(self.edge_color)
        if self.edge_fontcolor is not None:
            edge.set_fontcolor(self.edge_fontcolor)

        self.graph.add_edge(edge)
github markflorisson / minivect / pydot / pydot.py View on Github external
else:
        graph = Dot(graph_type='graph')

    for row in matrix:
        nodes = []
        c = 1

        for node in row:
            if node:
                nodes.append(c*node)
            c += 1
            nodes.sort()

        if len(nodes) == 2:
            graph.add_edge(
                Edge( node_prefix + abs(nodes[0]),
                    node_prefix + nodes[1] ))

    if not directed:
        graph.set_simplify(True)

    return graph
github markflorisson / minivect / pydot / pydot.py View on Github external
else:
        graph = Dot(graph_type='graph')

    for row in matrix:
        if not directed:
            skip = matrix.index(row)
            r = row[skip:]
        else:
            skip = 0
            r = row
        node_dest = skip+1

        for e in r:
            if e:
                graph.add_edge(
                    Edge( node_prefix + node_orig,
                        node_prefix + node_dest) )
            node_dest += 1
        node_orig += 1

    return graph
github markflorisson / minivect / pydot / pydot.py View on Github external
def get_edge_list(self):
        """Get the list of Edge instances.

        This method returns the list of Edge instances
        composing the graph.
        """

        edge_objs = list()

        for edge, obj_dict_list in self.obj_dict['edges'].iteritems():
                edge_objs.extend( [ Edge( obj_dict = obj_d ) for obj_d in obj_dict_list ] )

        return edge_objs
github markflorisson / minivect / pydot / pydot.py View on Github external
edge_points_reverse = (edge_points[1], edge_points[0])
        else:
            edge_points = (src_or_list, dst)
            edge_points_reverse = (dst, src_or_list)

        match = list()

        if self.obj_dict['edges'].has_key( edge_points ) or (
            self.get_top_graph_type() == 'graph' and self.obj_dict['edges'].has_key( edge_points_reverse )):

            edges_obj_dict = self.obj_dict['edges'].get(
                edge_points,
                self.obj_dict['edges'].get( edge_points_reverse, None ))

            for edge_obj_dict in edges_obj_dict:
                match.append( Edge( edge_points[0], edge_points[1], obj_dict = edge_obj_dict ) )

        return match
github markflorisson / minivect / pydot / pydot.py View on Github external
if obj['type'] == 'node':

                node = Node(obj_dict=obj)

                if self.obj_dict.get('suppress_disconnected', False):

                    if (node.get_name() not in edge_src_set and
                        node.get_name() not in edge_dst_set):

                        continue

                graph.append( node.to_string()+'\n' )

            elif obj['type'] == 'edge':

                edge = Edge(obj_dict=obj)

                if self.obj_dict.get('simplify', False) and edge in edges_done:
                    continue

                graph.append( edge.to_string() + '\n' )
                edges_done.add(edge)

            else:

                sgraph = Subgraph(obj_dict=obj)

                graph.append( sgraph.to_string()+'\n' )

        graph.append( '}\n' )

        return ''.join(graph)