How to use the pygraphviz.graphviz.agnameof function in pygraphviz

To help you get started, we’ve selected a few pygraphviz 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 networkx / networkx / networkx / drawing / nx_pygraphviz.py View on Github external
# just add edge
        def add_edge(e,a):
            N.add_edge(e[0],e[1])

    # graph                
    add_graph(dict(A.get_all_attr()))
    # loop through nodes            
    for node in A.nodes():
        name=pygraphviz.graphviz.agnameof(node.anode)
        add_node(name,A.get_all_attr(node=node))
    # loop through edges
    edges_seen = {}
    for edge in A.edges():
        if edge in edges_seen: continue
        source=pygraphviz.graphviz.agnameof(edge.source().anode)
        target=pygraphviz.graphviz.agnameof(edge.target().anode)
        edges_seen[edge]=1
        add_edge((source,target),A.get_all_attr(edge=(source,target)))
    return N
github philipaxer / pygraphviz / pygraphviz / agraph.py View on Github external
def __repr__(self):
        name=gv.agnameof(self.handle)
        if name is None:
            return '' %(self.handle)
        return '' %(name,self.handle)
github pygraphviz / pygraphviz / pygraphviz / agraph.py View on Github external
def get_name(self):
        name = gv.agnameof(self.handle)
        if name is not None:
            name = name.decode(self.encoding)
        return name
github pygraphviz / pygraphviz / pygraphviz / agraph.py View on Github external
def __new__(self, graph, name=None, nh=None):
        if nh is not None:
            n = super(Node, self).__new__(self, gv.agnameof(nh), graph.encoding)
        else:
            n = super(Node, self).__new__(self, name)
            try:
                nh = gv.agnode(graph.handle, n.encode(graph.encoding), _Action.find)
            except KeyError:
                raise KeyError("Node %s not in graph." % n)

        n.ghandle = graph.handle
        n.attr = ItemAttribute(nh, 1)
        n.handle = nh
        n.encoding = graph.encoding
        return n
github networkx / networkx / networkx / drawing / nx_pygraphviz.py View on Github external
else:
        # just add edge
        def add_edge(e,a):
            N.add_edge(e[0],e[1])

    # graph                
    add_graph(dict(A.get_all_attr()))
    # loop through nodes            
    for node in A.nodes():
        name=pygraphviz.graphviz.agnameof(node.anode)
        add_node(name,A.get_all_attr(node=node))
    # loop through edges
    edges_seen = {}
    for edge in A.edges():
        if edge in edges_seen: continue
        source=pygraphviz.graphviz.agnameof(edge.source().anode)
        target=pygraphviz.graphviz.agnameof(edge.target().anode)
        edges_seen[edge]=1
        add_edge((source,target),A.get_all_attr(edge=(source,target)))
    return N
github philipaxer / pygraphviz / pygraphviz / agraph.py View on Github external
def __new__(self,graph,name=None,nh=None):
        if nh is not None:
            n=unicode.__new__(self,gv.agnameof(nh))
        else:
            n=unicode.__new__(self,name)
            try:
                nh=gv.agnode(graph.handle,n,_Action.find)
            except KeyError:
                raise KeyError("Node %s not in graph."%n)

        n.ghandle=graph.handle
        n.attr=ItemAttribute(nh,1)
        n.handle=nh
        n.encoding=graph.encoding
        return n
github pygraphviz / pygraphviz / pygraphviz / agraph.py View on Github external
def clear(self):
        """Remove all nodes, edges, and attributes from the graph."""
        self.remove_edges_from(self.edges())
        self.remove_nodes_from(self.nodes())
        # now "close" existing graph and create a new graph
        name = gv.agnameof(self.handle)
        strict = self.strict
        directed = self.directed
        gv.agclose(self.handle)
        self.handle = gv.agraphnew(name, strict, directed)
        self._update_handle_references()
github philipaxer / pygraphviz / pygraphviz / agraph.py View on Github external
def get_name(self):
       name=gv.agnameof(self.handle)
       if name is not None:
           name=name.decode(self.encoding)
       return name