mirror of
https://hub.njuu.cf/TheAlgorithms/Python.git
synced 2023-10-11 13:06:12 +08:00
Fixes depth_first_search_2.py formatting
This commit is contained in:
parent
5e7e00b2ac
commit
fda3aed222
@ -56,7 +56,8 @@ class Graph:
|
||||
|
||||
def dfs(self) -> None:
|
||||
"""
|
||||
Perform depth-first search (DFS) traversal on the graph and print the visited vertices.
|
||||
Perform depth-first search (DFS) traversal on the graph
|
||||
and print the visited vertices.
|
||||
|
||||
Example:
|
||||
>>> g = Graph()
|
||||
@ -99,11 +100,12 @@ class Graph:
|
||||
# mark start vertex as visited
|
||||
visited[start_vertex] = True
|
||||
|
||||
print(start_vertex, end=" ")
|
||||
print(start_vertex, end="")
|
||||
|
||||
# Recur for all the vertices that are adjacent to this node
|
||||
for i in self.vertex:
|
||||
if not visited[i]:
|
||||
print(" ", end="")
|
||||
self.dfs_recursive(i, visited)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user