How to use the pygraphviz.graphviz.agnode 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 philipaxer / pygraphviz / pygraphviz / agraph.py View on Github external
(attribute values must be strings)

        >>> G.add_node(2,color='red')

        See http://www.graphviz.org/doc/info/attrs.html
        for a list of attributes.

        Anonymous Graphviz nodes are currently not implemented.

        """
        if not self._is_string_like(n):
            n=str(n)
        try:
            nh=gv.agnode(self.handle,n,_Action.find)
        except KeyError:
            nh=gv.agnode(self.handle,n,_Action.create)
            node=Node(self,nh=nh)
            node.attr.update(**attr)
github philipaxer / pygraphviz / pygraphviz / agraph.py View on Github external
Attributes can be added to nodes on creation
        (attribute values must be strings)

        >>> G.add_node(2,color='red')

        See http://www.graphviz.org/doc/info/attrs.html
        for a list of attributes.

        Anonymous Graphviz nodes are currently not implemented.

        """
        if not self._is_string_like(n):
            n=str(n)
        try:
            nh=gv.agnode(self.handle,n,_Action.find)
        except KeyError:
            nh=gv.agnode(self.handle,n,_Action.create)
            node=Node(self,nh=nh)
            node.attr.update(**attr)
github philipaxer / pygraphviz / pygraphviz / agraph.py View on Github external
def get_handle(self):
        """Return pointer to graphviz node object."""
        return gv.agnode(self.ghandle,self.encode(self.encoding),_Action.find)
github pygraphviz / pygraphviz / pygraphviz / agraph.py View on Github external
(attribute values must be strings)

        >>> G.add_node(2,color='red')

        See http://www.graphviz.org/doc/info/attrs.html
        for a list of attributes.

        Anonymous Graphviz nodes are currently not implemented.
        """
        if not is_string_like(n):
            n = str(n)
        n = n.encode(self.encoding)
        try:
            nh = gv.agnode(self.handle, n, _Action.find)
        except KeyError:
            nh = gv.agnode(self.handle, n, _Action.create)
        node = Node(self, nh=nh)
        node.attr.update(**attr)
github philipaxer / pygraphviz / pygraphviz / agraph.py View on Github external
def remove_node(self,n):
        """Remove the single node n.

        Attempting to remove a node that isn't in the graph will produce
        an error.

        >>> G=AGraph()
        >>> G.add_node('a')
        >>> G.remove_node('a')

        """
        if not self._is_string_like(n):
            n=str(n)
        try:
            nh=gv.agnode(self.handle,n,_Action.find)
            gv.agdelnode(self.handle,nh)
        except KeyError:
            raise KeyError("Node %s not in graph."%n.decode(self.encoding))
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 pygraphviz / pygraphviz / pygraphviz / agraph.py View on Github external
def remove_node(self, n):
        """Remove the single node n.

        Attempting to remove a node that isn't in the graph will produce
        an error.

        >>> G=AGraph()
        >>> G.add_node('a')
        >>> G.remove_node('a')
        """
        if not is_string_like(n):
            n = str(n)
        n = n.encode(self.encoding)
        try:
            nh = gv.agnode(self.handle, n, _Action.find)
            gv.agdelnode(self.handle, nh)
        except KeyError:
            raise KeyError("Node %s not in graph." % n.decode(self.encoding))