Skip to content

Commit

Permalink
Cosmetic changes
Browse files Browse the repository at this point in the history
  • Loading branch information
vanoha01 committed Oct 25, 2023
1 parent f96ec8f commit 392865f
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions sampo/userinput/parser/general_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,16 @@ def eliminate_cycle(self, cycle):
v = cycle[i + 1]

for neighbor, weight in self.graph[u]:
if neighbor == v and weight < min_weight:
if weight is None:
weight = 1
if neighbor == v and weight <= min_weight:
min_weight = weight
min_edge = (u, v)

u, v = min_edge
self.graph[u] = [(neighbor, weight) for neighbor, weight in self.graph[u] if neighbor != v]

def eliminate_cycles(self, eliminate_cycle: bool = True) -> list | None:
def eliminate_cycles(self, is_eliminate_cycle: bool = True) -> list | None:
cycle = self.find_cycle()
cycles = []

Expand All @@ -93,13 +95,14 @@ def eliminate_cycles(self, eliminate_cycle: bool = True) -> list | None:
if cycle[i] == cycle[-1]:
cycle = cycle[i:]
break
if not eliminate_cycle:
if not is_eliminate_cycle:
cycles.append(cycle)
self.eliminate_cycle(cycle)
else:
self.eliminate_cycle(cycle)
cycle = self.find_cycle()
if not eliminate_cycle:
if not cycles:
if not is_eliminate_cycle:
if cycles:
return cycles
return None
for v in self.graph:
Expand Down

0 comments on commit 392865f

Please sign in to comment.