mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-05 01:09:40 +08:00
[pre-commit.ci] pre-commit autoupdate (#12398)
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) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
![66853113+pre-commit-ci[bot]@users.noreply.github.com](/assets/img/avatar_default.png)
committed by
GitHub

parent
f3f32ae3ca
commit
fc33c50593
@ -133,18 +133,18 @@ def dijk(g, s):
|
||||
if len(known) == len(g) - 1:
|
||||
break
|
||||
mini = 100000
|
||||
for i in dist:
|
||||
if i not in known and dist[i] < mini:
|
||||
mini = dist[i]
|
||||
u = i
|
||||
for key, value in dist:
|
||||
if key not in known and value < mini:
|
||||
mini = value
|
||||
u = key
|
||||
known.add(u)
|
||||
for v in g[u]:
|
||||
if v[0] not in known and dist[u] + v[1] < dist.get(v[0], 100000):
|
||||
dist[v[0]] = dist[u] + v[1]
|
||||
path[v[0]] = u
|
||||
for i in dist:
|
||||
if i != s:
|
||||
print(dist[i])
|
||||
for key, value in dist.items():
|
||||
if key != s:
|
||||
print(value)
|
||||
|
||||
|
||||
"""
|
||||
@ -255,10 +255,10 @@ def prim(g, s):
|
||||
if len(known) == len(g) - 1:
|
||||
break
|
||||
mini = 100000
|
||||
for i in dist:
|
||||
if i not in known and dist[i] < mini:
|
||||
mini = dist[i]
|
||||
u = i
|
||||
for key, value in dist.items():
|
||||
if key not in known and value < mini:
|
||||
mini = value
|
||||
u = key
|
||||
known.add(u)
|
||||
for v in g[u]:
|
||||
if v[0] not in known and v[1] < dist.get(v[0], 100000):
|
||||
|
Reference in New Issue
Block a user