MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / initialize_unweighted_directed_graph

Function initialize_unweighted_directed_graph

graphs/basic_graphs.py:8–18  ·  view source on GitHub ↗
(
    node_count: int, edge_count: int
)

Source from the content-addressed store, hash-verified

6
7
8def initialize_unweighted_directed_graph(
9 node_count: int, edge_count: int
10) -> dict[int, list[int]]:
11 graph: dict[int, list[int]] = {}
12 for i in range(node_count):
13 graph[i + 1] = []
14
15 for e in range(edge_count):
16 x, y = (int(i) for i in _input(f"Edge {e + 1}: <node1> <node2> "))
17 graph[x].append(y)
18 return graph
19
20
21def initialize_unweighted_undirected_graph(

Callers

nothing calls this directly

Calls 2

_inputFunction · 0.85
appendMethod · 0.45

Tested by

no test coverage detected