Python: DFS Depth First Search

preview_player
Показать описание
Learn to code the DFS depth first search graph traversal algorithm in Python. I recommend you watch my DFS overview video first.

ALGORITHMS

Рекомендации по теме
Комментарии
Автор

That intro makes me feel like i have to run

cmhg
Автор

I love this! Thank you for going thru each line of code, absolute best video I've ever seen

bashierdahman
Автор

Thank you this is great!

I think lines 29-33's iteration unnecessarily increase the complexity.
I would replace it by a simple :


theophileavoyne
Автор

great example of dfs, understandable code and great explanation, I was looking for it for ages :)

Qizot
Автор

Thank you for this good concise explanation of code

mr_phamtastic
Автор

Thank you so much Joe. This really helped me a lot in understanding

priscillaroy
Автор

Great!!! Could make video about Hamiltonian cycles (directed/undirected graphs). It would be awesome)

ninano
Автор

Don't really understand the purpose of the global time variable. I thought the color of the vertices should be sufficient to say it has been visited? So why do we need the time?

wilsonlwtan
Автор

Thanks a lot for the video. How about the case when we have a directed graph, please?

ftakelait
Автор

Hello, how would you add a node counter to an already existing code.

priyankvenkatesh
Автор

hey Joe!, so the add_neighbors is a Vertex class method, and how are you using it in the Graph class(in the add_edge method)
without any Vertex.method() ?

anujtipparaju
Автор

This is helping me a ton. I am wondering why the graph class did not need the customary "__init__" function that I am so used to seeing.

lukeelliott
Автор

Why is there a BOSS MUSIC at the start of the video

ashutoshnegi
Автор

The code is available on my github site, and you can see the part-1 DFS video here, I recommend watching that video before this one.

oggiai
Автор

The explanations are amazing but the initial and final soundtrack is a torture to my ears

giampy
Автор

I have an error with this line of code
def print_graph(self):
for key in
print(key + + " " +
can anyone solve it?

AhmedAdel-qldt
Автор

hi! sorry for the stupid question, but does this code work for all types of examples of DFS?
ps: i have an exam on the 7th. please help

ouafaebouamar
Автор

line 40 is off the page, anyone know what it says or where to find the code? thanks

ippikineko
Автор

Hi, aspiring python dev here, often times when doing any graph search algorithm, do you normally have to build the graph and then build out your DFS as well? Or would you normally get a preconstructed graph?

thegrowers
Автор

What's the reason for using set in the addneighbours() definition? Shouldn''t the neighbours list not have any duplicates in the first place?

darkcaper