@@ -140,7 +140,9 @@ def find_central_node(
140
140
"""
141
141
valid_eccentricities = [e for e in eccentricities if e [1 ] != float ("inf" )]
142
142
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" )),
144
146
)
145
147
146
148
@@ -156,7 +158,9 @@ def find_median_node(closenesses: list[tuple[int, float]]) -> tuple[int, float]:
156
158
"""
157
159
valid_closenesses = [c for c in closenesses if c [1 ] != float ("inf" )]
158
160
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" )),
160
164
)
161
165
162
166
@@ -211,7 +215,7 @@ def find_central_and_median_node(
211
215
212
216
213
217
# Test cases included as doctests
214
- def test_single_node ():
218
+ def test_single_node () -> None :
215
219
"""
216
220
Test a graph with a single node.
217
221
@@ -225,7 +229,7 @@ def test_single_node():
225
229
"""
226
230
227
231
228
- def test_two_nodes_positive_weight ():
232
+ def test_two_nodes_positive_weight () -> None :
229
233
"""
230
234
Test a graph with two nodes connected by a positive weight.
231
235
@@ -239,7 +243,7 @@ def test_two_nodes_positive_weight():
239
243
"""
240
244
241
245
242
- def test_fully_connected_graph ():
246
+ def test_fully_connected_graph () -> None :
243
247
"""
244
248
Test a fully connected graph.
245
249
@@ -257,7 +261,7 @@ def test_fully_connected_graph():
257
261
"""
258
262
259
263
260
- def test_directed_acyclic_graph ():
264
+ def test_directed_acyclic_graph () -> None :
261
265
"""
262
266
Test a directed acyclic graph (DAG).
263
267
@@ -276,7 +280,7 @@ def test_directed_acyclic_graph():
276
280
"""
277
281
278
282
279
- def test_disconnected_graph ():
283
+ def test_disconnected_graph () -> None :
280
284
"""
281
285
Test a disconnected graph with nodes that cannot reach each other.
282
286
@@ -294,7 +298,7 @@ def test_disconnected_graph():
294
298
"""
295
299
296
300
297
- def test_graph_with_zero_weight ():
301
+ def test_graph_with_zero_weight () -> None :
298
302
"""
299
303
Test a graph with zero weight, which should raise a ValueError.
300
304
@@ -306,7 +310,7 @@ def test_graph_with_zero_weight():
306
310
"""
307
311
308
312
309
- def test_graph_with_negative_weight ():
313
+ def test_graph_with_negative_weight () -> None :
310
314
"""
311
315
Test a graph with negative weight, which should raise a ValueError.
312
316
@@ -318,7 +322,7 @@ def test_graph_with_negative_weight():
318
322
"""
319
323
320
324
321
- def test_cyclic_graph ():
325
+ def test_cyclic_graph () -> None :
322
326
"""
323
327
Test a cyclic graph where there is a cycle between nodes.
324
328
@@ -336,7 +340,7 @@ def test_cyclic_graph():
336
340
"""
337
341
338
342
339
- def test_sparse_graph ():
343
+ def test_sparse_graph () -> None :
340
344
"""
341
345
Test a larger sparse graph.
342
346
@@ -356,7 +360,7 @@ def test_sparse_graph():
356
360
"""
357
361
358
362
359
- def test_large_fully_connected_graph ():
363
+ def test_large_fully_connected_graph () -> None :
360
364
"""
361
365
Test a larger fully connected graph with random weights.
362
366
0 commit comments