Skip to content

Commit 6f7a2de

Browse files
committed
Implement style changes suggested by bot.
1 parent d4855d3 commit 6f7a2de

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

graphs/graph_centrality.py

+16-12
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,9 @@ def find_central_node(
140140
"""
141141
valid_eccentricities = [e for e in eccentricities if e[1] != float("inf")]
142142
return min(
143-
valid_eccentricities, key=lambda x: (x[1], x[0]), default=(-1, float("inf"))
143+
valid_eccentricities,
144+
key=lambda node_eccentricity: (node_eccentricity[1], node_eccentricity[0]),
145+
default=(-1, float("inf")),
144146
)
145147

146148

@@ -156,7 +158,9 @@ def find_median_node(closenesses: list[tuple[int, float]]) -> tuple[int, float]:
156158
"""
157159
valid_closenesses = [c for c in closenesses if c[1] != float("inf")]
158160
return max(
159-
valid_closenesses, key=lambda x: (x[1], -x[0]), default=(-1, float("inf"))
161+
valid_closenesses,
162+
key=lambda node_closeness: (node_closeness[1], -node_closeness[0]),
163+
default=(-1, float("inf")),
160164
)
161165

162166

@@ -211,7 +215,7 @@ def find_central_and_median_node(
211215

212216

213217
# Test cases included as doctests
214-
def test_single_node():
218+
def test_single_node() -> None:
215219
"""
216220
Test a graph with a single node.
217221
@@ -225,7 +229,7 @@ def test_single_node():
225229
"""
226230

227231

228-
def test_two_nodes_positive_weight():
232+
def test_two_nodes_positive_weight() -> None:
229233
"""
230234
Test a graph with two nodes connected by a positive weight.
231235
@@ -239,7 +243,7 @@ def test_two_nodes_positive_weight():
239243
"""
240244

241245

242-
def test_fully_connected_graph():
246+
def test_fully_connected_graph() -> None:
243247
"""
244248
Test a fully connected graph.
245249
@@ -257,7 +261,7 @@ def test_fully_connected_graph():
257261
"""
258262

259263

260-
def test_directed_acyclic_graph():
264+
def test_directed_acyclic_graph() -> None:
261265
"""
262266
Test a directed acyclic graph (DAG).
263267
@@ -276,7 +280,7 @@ def test_directed_acyclic_graph():
276280
"""
277281

278282

279-
def test_disconnected_graph():
283+
def test_disconnected_graph() -> None:
280284
"""
281285
Test a disconnected graph with nodes that cannot reach each other.
282286
@@ -294,7 +298,7 @@ def test_disconnected_graph():
294298
"""
295299

296300

297-
def test_graph_with_zero_weight():
301+
def test_graph_with_zero_weight() -> None:
298302
"""
299303
Test a graph with zero weight, which should raise a ValueError.
300304
@@ -306,7 +310,7 @@ def test_graph_with_zero_weight():
306310
"""
307311

308312

309-
def test_graph_with_negative_weight():
313+
def test_graph_with_negative_weight() -> None:
310314
"""
311315
Test a graph with negative weight, which should raise a ValueError.
312316
@@ -318,7 +322,7 @@ def test_graph_with_negative_weight():
318322
"""
319323

320324

321-
def test_cyclic_graph():
325+
def test_cyclic_graph() -> None:
322326
"""
323327
Test a cyclic graph where there is a cycle between nodes.
324328
@@ -336,7 +340,7 @@ def test_cyclic_graph():
336340
"""
337341

338342

339-
def test_sparse_graph():
343+
def test_sparse_graph() -> None:
340344
"""
341345
Test a larger sparse graph.
342346
@@ -356,7 +360,7 @@ def test_sparse_graph():
356360
"""
357361

358362

359-
def test_large_fully_connected_graph():
363+
def test_large_fully_connected_graph() -> None:
360364
"""
361365
Test a larger fully connected graph with random weights.
362366

0 commit comments

Comments
 (0)