

def nbunch_iter(self, nbunch=None):
    'Return an iterator of nodes contained in nbunch that are\n        also in the graph.\n\n        The nodes in nbunch are checked for membership in the graph\n        and if not are silently ignored.\n\n        Parameters\n        ----------\n        nbunch : iterable container, optional (default=all nodes)\n            A container of nodes.  The container will be iterated\n            through once.\n\n        Returns\n        -------\n        niter : iterator\n            An iterator over nodes in nbunch that are also in the graph.\n            If nbunch is None, iterate over all nodes in the graph.\n\n        Raises\n        ------\n        NetworkXError\n            If nbunch is not a node or or sequence of nodes.\n            If a node in nbunch is not hashable.\n\n        See Also\n        --------\n        Graph.__iter__\n\n        Notes\n        -----\n        When nbunch is an iterator, the returned iterator yields values\n        directly from nbunch, becoming exhausted when nbunch is exhausted.\n\n        To test whether nbunch is a single node, one can use\n        "if nbunch in self:", even after processing with this routine.\n\n        If nbunch is not a node or a (possibly empty) sequence/iterator\n        or None, a NetworkXError is raised.  Also, if any object in\n        nbunch is not hashable, a NetworkXError is raised.\n        '
    if (nbunch is None):
        bunch = iter(self.adj.keys())
    elif (nbunch in self):
        bunch = iter([nbunch])
    else:

        def bunch_iter(nlist, adj):
            try:
                for n in nlist:
                    if (n in adj):
                        (yield n)
            except TypeError as e:
                message = e.args[0]
                import sys
                sys.stdout.write(message)
                if ('iter' in message):
                    raise NetworkXError('nbunch is not a node or a sequence of nodes.')
                elif ('hashable' in message):
                    raise NetworkXError(('Node %s in the sequence nbunch is not a valid node.' % n))
                else:
                    raise
        bunch = bunch_iter(nbunch, self.adj)
    return self

dataset/ETHPy150Open networkx/networkx/networkx/classes/tests/timingclasses.py TimingGraph.nbunch_iter/VarMisuse@187/762 `bunch`->`self`