networkx.Graph.has_neighbor
networkx.Graph.selfloop_edges
Return a list of nodes with self loops.
Examples
>>> G=nx.Graph() >>> G.add_edge(1,1) >>> G.add_edge(1,2) >>> G.nodes_with_selfloops() [1]