

def degree_iter(self, nbunch=None, weight=None):
    'Return an iterator for (node, degree).\n\n        The node degree is the number of edges adjacent 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, degree).\n\n        See Also\n        --------\n        degree, in_degree, out_degree, in_degree_iter, out_degree_iter\n\n        Examples\n        --------\n        >>> G = nx.DiGraph()   # or MultiDiGraph\n        >>> G.add_path([0,1,2,3])\n        >>> list(G.degree_iter(0)) # node 0 with degree 1\n        [(0, 1)]\n        >>> list(G.degree_iter([0,1]))\n        [(0, 1), (1, 2)]\n\n        '
    if (nbunch is None):
        nodes_nbrs = zip(iter(self.succ.items()), iter(self.pred.items()))
    else:
        nodes_nbrs = zip(((n, self.succ[n]) for n in self.nbunch_iter(nbunch)), ((n2, self.pred[n]) for n in self.nbunch_iter(nbunch)))
    if (weight is None):
        for ((n, succ), (n2, pred)) in nodes_nbrs:
            (yield (n, (len(succ) + len(pred))))
    else:
        for ((n, succ), (n2, pred)) in nodes_nbrs:
            (yield (n, (sum((succ[nbr].get(weight, 1) for nbr in succ)) + sum((pred[nbr].get(weight, 1) for nbr in pred)))))

dataset/ETHPy150Open networkx/networkx/networkx/classes/tests/timingclasses.py TimingDiGraph.degree_iter/VarMisuse@89/516 `n`->`n2`