

def selfloop_edges(self, data=False, keys=False):
    'Return a list of selfloop edges.\n\n        A selfloop edge has the same node at both ends.\n\n        Parameters\n        -----------\n        data : bool, optional (default=False)\n            Return selfloop edges as two tuples (u,v) (data=False)\n            or three-tuples (u,v,data) (data=True)\n        keys : bool, optional (default=False)\n            If True, return edge keys with each edge.\n\n        Returns\n        -------\n        edgelist : list of edge tuples\n            A list of all selfloop edges.\n\n        See Also\n        --------\n        nodes_with_selfloops, number_of_selfloops\n\n        Examples\n        --------\n        >>> G = nx.MultiGraph()   # or MultiDiGraph\n        >>> G.add_edge(1,1)\n        >>> G.add_edge(1,2)\n        >>> G.selfloop_edges()\n        [(1, 1)]\n        >>> G.selfloop_edges(data=True)\n        [(1, 1, {})]\n        >>> G.selfloop_edges(keys=True)\n        [(1, 1, 0)]\n        >>> G.selfloop_edges(keys=True, data=True)\n        [(1, 1, 0, {})]\n        '
    if data:
        if keys:
            return [(n, n, k, d) for (n, nbrs) in self.adj.items() if (n in nbrs) for (k, d) in nbrs[n].items()]
        else:
            return [(n, data, d) for (n, nbrs) in self.adj.items() if (n in nbrs) for d in nbrs[n].values()]
    elif keys:
        return [(n, n, k) for (n, nbrs) in self.adj.items() if (n in nbrs) for k in nbrs[n].keys()]
    else:
        return [(n, n) for (n, nbrs) in self.adj.items() if (n in nbrs) for d in nbrs[n].values()]

dataset/ETHPy150Open networkx/networkx/networkx/classes/tests/timingclasses.py TimingMultiGraph.selfloop_edges/VarMisuse@88/481 `n`->`data`