DEV Community

MokhtarEbrahim
MokhtarEbrahim

Posted on

2

Depth First Search algorithm in Python (Multiple Examples)

1 Introduction
2 The Depth First Search Algorithm
3 Representing a graph
3.1 Adjacency Matrix
3.2 Adjacency List
4 Implementing Depth First Search(a non-recursive approach)
5 DFS using a recursive method
6 Depth First Search on a Binary Tree
6.1 What is a Binary Tree?
6.2 Representing Binary Trees using Python classes
6.3 Implementing DFS for a binary tree
7 Depth First Search using networkx
7.1 Constructing a graph in networkx
7.2 Visualizing the graph in DFS
7.3 Graph traversal in networkx – DFS
8 Topological sorting using Depth First Search
9 Finding connected components using DFS
10 Conclusion

https://likegeeks.com/depth-first-search-in-python/

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Engage with a wealth of insights in this thoughtful article, valued within the supportive DEV Community. Coders of every background are welcome to join in and add to our collective wisdom.

A sincere "thank you" often brightens someone’s day. Share your gratitude in the comments below!

On DEV, the act of sharing knowledge eases our journey and fortifies our community ties. Found value in this? A quick thank you to the author can make a significant impact.

Okay