#NEWLINE# def selfloop_edges( self , data = False , keys = False , default = None ) : #NEWLINE# #INDENT# "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,datadict) (data=True)\n            or three-tuples (u,v,datavalue) (data='attrname')\n        default : value, optional (default=None)\n            Value used for edges that dont have the requested attribute.\n            Only relevant if data is not True or False.\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        >>> list(G.selfloop_edges())\n        [(1, 1)]\n        >>> list(G.selfloop_edges(data=True))\n        [(1, 1, {})]\n        >>> list(G.selfloop_edges(keys=True))\n        [(1, 1, 0)]\n        >>> list(G.selfloop_edges(keys=True, data=True))\n        [(1, 1, 0, {})]\n        " #NEWLINE# if ( data is True ) : #NEWLINE# #INDENT# if keys : #NEWLINE# #INDENT# return ( ( n , n , k , d ) for ( n , nbrs ) in self . adj . items ( ) if ( n in nbrs ) for ( k , d ) in nbrs [ n ] . items ( ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return ( ( n , n , d ) for ( n , nbrs ) in self . adj . items ( ) if ( n in nbrs ) for d in nbrs [ n ] . values ( ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( data is not False ) : #NEWLINE# #INDENT# if keys : #NEWLINE# #INDENT# return ( ( n , n , k , d . get ( data , default ) ) for ( n , nbrs ) in self . adj . items ( ) if ( n in nbrs ) for ( k , d ) in nbrs [ n ] . items ( ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return ( ( n , n , d . get ( data , default ) ) for ( n , nbrs ) in self . adj . items ( ) if ( n in nbrs ) for d in nbrs [ n ] . values ( ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if keys : #NEWLINE# #INDENT# return ( ( n , n , k ) for ( n , nbrs ) in self . adj . items ( ) if ( n in nbrs ) for k in nbrs [ n ] . keys ( ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return ( ( n , n ) for ( n , nbrs ) in self . adj . items ( ) if ( n in nbrs ) for d in nbrs [ n ] . values ( ) )