

def in_degree_iter(self, nbunch=None, weight=None):
    'Return an iterator for (node, in-degree).\n\n        The node in-degree is the number of edges pointing in to the node.\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        weight : string or None, optional (default=None)\n           The edge attribute that holds the numerical value used \n           as a weight.  If None, then each edge has weight 1.\n           The degree is the sum of the edge weights adjacent to the node.\n\n        Returns\n        -------\n        nd_iter : an iterator\n            The iterator returns two-tuples of (node, in-degree).\n\n        See Also\n        --------\n        degree, in_degree, out_degree, out_degree_iter\n\n        Examples\n        --------\n        >>> G = nx.MultiDiGraph()\n        >>> G.add_path([0,1,2,3])\n        >>> list(G.in_degree_iter(0)) # node 0 with degree 0\n        [(0, 0)]\n        >>> list(G.in_degree_iter([0,1]))\n        [(0, 0), (1, 1)]\n\n        '
    if (nbunch is None):
        nodes_nbrs = self.pred.items()
    else:
        nodes_nbrs = ((n, self.pred[n]) for n in self.nbunch_iter(nbunch))
    if (weight is None):
        for (n, nbrs) in nodes_nbrs:
            (yield (n, sum([len(data) for data in nbrs.values()])))
    else:
        for (n, pred) in nodes_nbrs:
            deg = sum([d.get(weight, 1) for data in pred.values() for d in data.values()])
            (yield (n, deg))

dataset/ETHPy150Open networkx/networkx/networkx/classes/tests/timingclasses.py TimingMultiDiGraph.in_degree_iter/original