mirror of
https://github.com/TheAlgorithms/Python.git
synced 2026-03-13 09:50:19 +08:00
[pre-commit.ci] pre-commit autoupdate (#11473)
* [pre-commit.ci] pre-commit autoupdate updates: - [github.com/astral-sh/ruff-pre-commit: v0.4.10 → v0.5.0](https://github.com/astral-sh/ruff-pre-commit/compare/v0.4.10...v0.5.0) - [github.com/pre-commit/mirrors-mypy: v1.10.0 → v1.10.1](https://github.com/pre-commit/mirrors-mypy/compare/v1.10.0...v1.10.1) * Fix ruff issues * Fix ruff issues --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Christian Clauss <cclauss@me.com>
This commit is contained in:
committed by
GitHub
parent
6882a8b808
commit
716bdeb68b
@@ -156,9 +156,11 @@ class GraphAdjacencyMatrix(Generic[T]):
|
||||
self.vertex_to_index.pop(vertex)
|
||||
|
||||
# decrement indices for vertices shifted by the deleted vertex in the adj matrix
|
||||
for vertex in self.vertex_to_index:
|
||||
if self.vertex_to_index[vertex] >= start_index:
|
||||
self.vertex_to_index[vertex] = self.vertex_to_index[vertex] - 1
|
||||
for inner_vertex in self.vertex_to_index:
|
||||
if self.vertex_to_index[inner_vertex] >= start_index:
|
||||
self.vertex_to_index[inner_vertex] = (
|
||||
self.vertex_to_index[inner_vertex] - 1
|
||||
)
|
||||
|
||||
def contains_vertex(self, vertex: T) -> bool:
|
||||
"""
|
||||
|
||||
@@ -123,9 +123,7 @@ def do_something(back_pointer, goal, start):
|
||||
def valid(p: TPos):
|
||||
if p[0] < 0 or p[0] > n - 1:
|
||||
return False
|
||||
if p[1] < 0 or p[1] > n - 1:
|
||||
return False
|
||||
return True
|
||||
return not (p[1] < 0 or p[1] > n - 1)
|
||||
|
||||
|
||||
def expand_state(
|
||||
|
||||
@@ -103,4 +103,4 @@ if __name__ == "__main__":
|
||||
edges = list(zip(source, target))
|
||||
g = create_graph(n_vertices, edges)
|
||||
|
||||
assert [[5], [6], [4], [3, 2, 1, 0]] == tarjan(g)
|
||||
assert tarjan(g) == [[5], [6], [4], [3, 2, 1, 0]]
|
||||
|
||||
Reference in New Issue
Block a user