[[NetworkX]]で効率的に全てのエッジをたどりたい。 ```python for (u, v) in G.edges: pass ``` 隣接ノード経由でたどる。 > Often the best way to traverse all edges of a graph is via the neighbors. The neighbors are reported as an adjacency-dict G.adj or G.adjacency() [DiGraph—Directed graphs with self loops — NetworkX 2.7 documentation](https://networkx.org/documentation/stable/reference/classes/digraph.html) ```python for n, nbrsdict in G.adjacency(): for nbr, eattr in nbrsdict.items(): if "weight" in eattr: # Do something useful with the edges pass ```