Returns an iterator of Edge objects for the given list of nodes. It yields None where two successive nodes are not connected.
(path)
| 741 | return _root and sorted(p, key=len) or p |
| 742 | |
| 743 | def edges(path): |
| 744 | """ Returns an iterator of Edge objects for the given list of nodes. |
| 745 | It yields None where two successive nodes are not connected. |
| 746 | """ |
| 747 | # For example, the distance (i.e., edge weight sum) of a path: |
| 748 | # sum(e.weight for e in edges(path)) |
| 749 | return len(path) > 1 and (n.links.edge(path[i+1]) for i,n in enumerate(path[:-1])) or iter(()) |
| 750 | |
| 751 | #--- GRAPH THEORY ---------------------------------------------------------------------------------- |
| 752 |