Skip to content

Dfs#25

Open
Quark1111 wants to merge 1 commit intomainfrom
DFS
Open

Dfs#25
Quark1111 wants to merge 1 commit intomainfrom
DFS

Conversation

@Quark1111
Copy link
Owner

No description provided.

@Quark1111 Quark1111 requested a review from chernishev December 7, 2025 20:09
Comment on lines +25 to +33
while self.stack:
vertex = self.stack.pop()

if vertex not in self.visited:
self.visited.append(vertex)

for neighbor in self.directed[vertex]:
if neighbor not in self.visited:
self.stack.append(neighbor)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не нужно занаво реализовывать DFS, тем более другой реализацией, нежели до этого. Используй изначальную функцию DFS, итерируйся по её выводу.

return vertex

Tops = int(input("введите количество вершин: "))
mas = []

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Неиспользуемая переменная

@Sneper-Breeze
Copy link

Нужно реализовать структуру так, чтобы я мог задавать любые графы, в том числе и с вершинами, которые ни с кем не связаны. У тебя сейчас немного костыльно это.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants