Skip to content

Commit 5a8f446

Browse files
committed
#9943 : Adding coverage test for basic_graphs.py
1 parent 2daf7c3 commit 5a8f446

File tree

1 file changed

+3
-29
lines changed

1 file changed

+3
-29
lines changed

graphs/basic_graphs.py

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,7 @@ def _input(message):
88
def initialize_unweighted_directed_graph(
99
node_count: int, edge_count: int
1010
) -> dict[int, list[int]]:
11-
"""
12-
Example:
13-
Edge 1: <node1> <node2> 1 2
14-
Edge 2: <node1> <node2> 3 2
15-
Edge 3: <node1> <node2> 2 4
16-
>>> import io, sys ; sys.stdin = io.StringIO(chr(10).join(['1 2','3 2', '2 4'])) # input
17-
>>> initialize_unweighted_directed_graph(4, 3)
18-
Edge 1: <node1> <node2> Edge 2: <node1> <node2> Edge 3: <node1> <node2> {1: [2], 2: [4], 3: [2], 4: []}
19-
"""
11+
2012
graph: dict[int, list[int]] = {}
2113
for i in range(node_count):
2214
graph[i + 1] = []
@@ -30,15 +22,7 @@ def initialize_unweighted_directed_graph(
3022
def initialize_unweighted_undirected_graph(
3123
node_count: int, edge_count: int
3224
) -> dict[int, list[int]]:
33-
"""
34-
Example:
35-
Edge 1: <node1> <node2> 1 2
36-
Edge 2: <node1> <node2> 3 2
37-
Edge 3: <node1> <node2> 2 4
38-
>>> import io, sys ; sys.stdin = io.StringIO(chr(10).join(['1 2','3 2', '2 4'])) # input
39-
>>> initialize_unweighted_undirected_graph(4, 3)
40-
Edge 1: <node1> <node2> Edge 2: <node1> <node2> Edge 3: <node1> <node2> {1: [2], 2: [1, 3, 4], 3: [2], 4: [2]}
41-
"""
25+
4226
graph: dict[int, list[int]] = {}
4327
for i in range(node_count):
4428
graph[i + 1] = []
@@ -53,17 +37,7 @@ def initialize_unweighted_undirected_graph(
5337
def initialize_weighted_undirected_graph(
5438
node_count: int, edge_count: int
5539
) -> dict[int, list[tuple[int, int]]]:
56-
"""
57-
Example:
58-
Edge 1: <node1> <node2> <weight> 1 2 1
59-
Edge 2: <node1> <node2> <weight> 3 2 6
60-
Edge 3: <node1> <node2> <weight> 2 4 10
61-
Edge 4: <node1> <node2> <weight> 4 1 7
62-
Edge 5: <node1> <node2> <weight> 4 3 12
63-
>>> import io, sys ; sys.stdin = io.StringIO(chr(10).join(['1 2 1','3 2 6', '2 4 10', '4 1 7', '4 3 12'])) # input
64-
>>> initialize_weighted_undirected_graph(4, 5)
65-
Edge 1: <node1> <node2> <weight> Edge 2: <node1> <node2> <weight> Edge 3: <node1> <node2> <weight> Edge 4: <node1> <node2> <weight> Edge 5: <node1> <node2> <weight> {1: [(2, 1), (4, 7)], 2: [(1, 1), (3, 6), (4, 10)], 3: [(2, 6), (4, 12)], 4: [(2, 10), (1, 7), (3, 12)]}
66-
"""
40+
6741
graph: dict[int, list[tuple[int, int]]] = {}
6842
for i in range(node_count):
6943
graph[i + 1] = []

0 commit comments

Comments
 (0)