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

def networkx::base::Graph::edge_boundary (   self,
  nbunch1,
  nbunch2 = None 
) [inherited]

Return list of edges (n1,n2) with n1 in nbunch1 and n2 in
nbunch2.  If nbunch2 is omitted or nbunch2=None, then nbunch2
is all nodes not in nbunch1.

Nodes in nbunch1 and nbunch2 that are not in the graph are
ignored.

nbunch1 and nbunch2 must be disjoint, else raise an exception.

Definition at line 713 of file base.py.

00713                                                   :
        """Return list of edges (n1,n2) with n1 in nbunch1 and n2 in
        nbunch2.  If nbunch2 is omitted or nbunch2=None, then nbunch2
        is all nodes not in nbunch1.

        Nodes in nbunch1 and nbunch2 that are not in the graph are
        ignored.

        nbunch1 and nbunch2 must be disjoint, else raise an exception.

        """
        bdy=[]
        # listify to avoid exhausting a once-through iterable container
        # nlist1 and nlist2 contains only nodes that are in the graph
        nlist1=[n for n in nbunch1 if n in self]
        len1=len(nlist1)

        if nbunch2 is None: # use nbunch2 = complement of nbunch1
            nlist2=[n for n in self if n not in nlist1]
            len2=len(nlist2) # size of node complement
        else:
            nlist2=[n for n in nbunch2 if n in self]
            len2=len(nlist2)
            # check for non-empty intersection:
            # nbunch1, nbunch2 and self.nodes() should have no nodes
            # in common
            # use shortest outer loop
            if len1 <= len2:
                for n in nlist1:
                    if n in nlist2:
                        raise NetworkXError,\
                        "nbunch1 and nbunch2 are not disjoint"
            else:
                for n in nlist2:
                    if n in nlist1:
                        raise NetworkXError, \
                        "nbunch1 and nbunch2 are not disjoint"
        if len1 <= len2:
            for n1 in nlist1:
                for n2 in self.adj[n1]:
                    if n2 in nlist2:
                        bdy.append((n1,n2))
        elif len2 <= len1:
            for n2 in nlist2:
                for n1 in self.adj[n2]:
                    if n1 in nlist1:
                        bdy.append((n1,n2))
        return bdy

    def node_boundary(self, nbunch1, nbunch2=None):


Generated by  Doxygen 1.6.0   Back to index