MCPcopy Create free account
hub / github.com/Graphify-Labs/graphify / edge_data

Function edge_data

graphify/build.py:1298–1308  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

1296
1297
1298def 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
1311def edge_datas(G: nx.Graph, u: str, v: str) -> list[dict]:

Calls

no outgoing calls