Return one edge attribute dict for (u, v), tolerating MultiGraph. For MultiGraph/MultiDiGraph there can be multiple parallel edges; this returns the first one (sufficient for callers that only need relation/confidence for rendering). Fixes #796.
(G: nx.Graph, u: str, v: str)
| 1296 | |
| 1297 | |
| 1298 | def edge_data(G: nx.Graph, u: str, v: str) -> dict: |
| 1299 | """Return one edge attribute dict for (u, v), tolerating MultiGraph. |
| 1300 | |
| 1301 | For MultiGraph/MultiDiGraph there can be multiple parallel edges; |
| 1302 | this returns the first one (sufficient for callers that only need |
| 1303 | relation/confidence for rendering). Fixes #796. |
| 1304 | """ |
| 1305 | raw = G[u][v] |
| 1306 | if isinstance(G, (nx.MultiGraph, nx.MultiDiGraph)): |
| 1307 | return next(iter(raw.values()), {}) |
| 1308 | return raw |
| 1309 | |
| 1310 | |
| 1311 | def edge_datas(G: nx.Graph, u: str, v: str) -> list[dict]: |
no outgoing calls