Skip to content

Commit 9e7a34a

Browse files
committed
Fix style issues (flake8)
1 parent d8cd6fd commit 9e7a34a

File tree

4 files changed

+20
-21
lines changed

4 files changed

+20
-21
lines changed

graphs/graph_adjacency_list.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,10 +235,10 @@ def __generate_random_edges(
235235
assert edge_pick_count <= len(vertices)
236236

237237
random_source_vertices: list[int] = random.sample(
238-
vertices[0 : int(len(vertices) / 2)], edge_pick_count
238+
vertices[0: int(len(vertices) / 2)], edge_pick_count
239239
)
240240
random_destination_vertices: list[int] = random.sample(
241-
vertices[int(len(vertices) / 2) :], edge_pick_count
241+
vertices[int(len(vertices) / 2):], edge_pick_count
242242
)
243243
random_edges: list[list[int]] = []
244244

graphs/graph_adjacency_matrix.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,10 +246,10 @@ def __generate_random_edges(
246246
assert edge_pick_count <= len(vertices)
247247

248248
random_source_vertices: list[int] = random.sample(
249-
vertices[0 : int(len(vertices) / 2)], edge_pick_count
249+
vertices[0: int(len(vertices) / 2)], edge_pick_count
250250
)
251251
random_destination_vertices: list[int] = random.sample(
252-
vertices[int(len(vertices) / 2) :], edge_pick_count
252+
vertices[int(len(vertices) / 2):], edge_pick_count
253253
)
254254
random_edges: list[list[int]] = []
255255

graphs/heavy_light_decomposition.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,19 +126,19 @@ def query_path(
126126
while self.head[u] != self.head[v]:
127127
if self.depth[self.head[u]] > self.depth[self.head[v]]:
128128
# Query from head[u] to u
129-
segment = self.base_array[self.pos[self.head[u]] : self.pos[u] + 1]
129+
segment = self.base_array[self.pos[self.head[u]]: self.pos[u] + 1]
130130
res.extend(segment)
131131
u = self.parent[self.head[u]]
132132
else:
133-
segment = self.base_array[self.pos[self.head[v]] : self.pos[v] + 1]
133+
segment = self.base_array[self.pos[self.head[v]]: self.pos[v] + 1]
134134
res.extend(segment)
135135
v = self.parent[self.head[v]]
136136

137137
# Same chain now
138138
l, r = self.pos[u], self.pos[v]
139139
if l > r:
140140
l, r = r, l
141-
segment = self.base_array[l : r + 1]
141+
segment = self.base_array[l: r + 1]
142142
res.extend(segment)
143143

144144
return operation(res) if res else 0

graphs/tests/test_graph_algorithms.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,26 @@
33
Run with: pytest tests/test_graph_algorithms.py -v
44
"""
55

6+
from graphs.max_bipartite_independent_set import (
7+
MaxBipartiteIndependentSet,
8+
max_bipartite_independent_set,
9+
)
10+
from graphs.heavy_light_decomposition import HeavyLightDecomposition
11+
from graphs.traveling_salesman import TravelingSalesman, held_karp
12+
from graphs.chinese_postman import ChinesePostman, chinese_postman
13+
from graphs.two_sat import TwoSAT, solve_2sat
14+
from graphs.push_relabel import PushRelabel
15+
from graphs.ford_fulkerson import FordFulkerson, ford_fulkerson
16+
from graphs.hopcroft_karp import HopcroftKarp, hopcroft_karp
17+
from graphs.johnsons_algorithm import johnsons_algorithm
18+
from graphs.floyd_warshall import floyd_warshall, reconstruct_path
619
import pytest
720
import sys
821
import os
922

1023
# Add parent directory to path
1124
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
1225

13-
from graphs.floyd_warshall import floyd_warshall, reconstruct_path
14-
from graphs.johnsons_algorithm import johnsons_algorithm
15-
from graphs.hopcroft_karp import HopcroftKarp, hopcroft_karp
16-
from graphs.ford_fulkerson import FordFulkerson, ford_fulkerson
17-
from graphs.push_relabel import PushRelabel
18-
from graphs.two_sat import TwoSAT, solve_2sat
19-
from graphs.chinese_postman import ChinesePostman, chinese_postman
20-
from graphs.traveling_salesman import TravelingSalesman, held_karp
21-
from graphs.heavy_light_decomposition import HeavyLightDecomposition
22-
from graphs.max_bipartite_independent_set import (
23-
MaxBipartiteIndependentSet,
24-
max_bipartite_independent_set,
25-
)
26-
2726

2827
class TestFloydWarshall:
2928
"""Test Floyd-Warshall all-pairs shortest path."""

0 commit comments

Comments
 (0)