MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / _collect_nodes_and_edges

Function _collect_nodes_and_edges

graphs/johnson.py:9–17  ·  view source on GitHub ↗
(graph: adjacency)

Source from the content-addressed store, hash-verified

7
8
9def _collect_nodes_and_edges(graph: adjacency) -> tuple[list[Node], list[edge]]:
10 nodes = set()
11 edges: list[edge] = []
12 for u, neighbors in graph.items():
13 nodes.add(u)
14 for v, w in neighbors:
15 nodes.add(v)
16 edges.append((u, v, w))
17 return list(nodes), edges
18
19
20def _bellman_ford(nodes: list[Node], edges: list[edge]) -> dict[Node, float]:

Callers 1

johnsonFunction · 0.85

Calls 2

addMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected