Logo Search packages:      
Sourcecode: python-networkx version File versions  Download package

def networkx::base::Graph::add_edges_from (   self,
  ebunch 
)

Add all the edges in ebunch to the graph.

ebunch: Container of 2-tuples (u,v). The container must be
iterable or an iterator.  It is iterated over once. Adding the
same edge twice has no effect and does not raise an exception.

Reimplemented in networkx::base::DiGraph, networkx::tree::Tree, networkx::xbase::XGraph, and networkx::xbase::XDiGraph.

Definition at line 588 of file base.py.

00588                                     :  
        """Add all the edges in ebunch to the graph.

        ebunch: Container of 2-tuples (u,v). The container must be
        iterable or an iterator.  It is iterated over once. Adding the
        same edge twice has no effect and does not raise an exception.

        """
        for e in ebunch:
            (u,v)=e
            # add nodes
            if u not in self.adj:
                self.adj[u]={}
            if v not in self.adj:
                self.adj[v]={}
            # don't create self loops, fail silently, nodes are still added
            if u==v:
                continue  
            self.adj[u][v]=None
            self.adj[v][u]=None # add both u-v and v-u



Generated by  Doxygen 1.6.0   Back to index