<｜begin▁of▁sentence｜>### Instruction:
I have a graph with some nodes and edges, including self-loops. I want to identify all the selfloop edges. The graph has the following edges: (1, 1) as a selfloop and (1, 2) as a regular edge. How can I find the selfloop edges?
### Response:
import networkx as nx

# Create a graph of your preferred type
G = nx.MultiGraph()

# Add selfloop and non-selfloop edges
ekey = G.add_edge(1, 1)
ekey = G.add_edge(1, 2)

# Use selfloop_edges to find selfloop edges in the graph
selfloops = list(nx.selfloop_edges(G, data=True))
print('Selfloop edges:', selfloops)
<|EOT|>
