BFS is one of the basic algorithm for graph traversal. BFS uses a queue to keep track of visited nodes. The basic idea behind the BFS is to visit the adjacent nodes of the starting node, keep them in the queue and mark them as visisted. Then pick up the next node from the queue […]

## Implementing DFS (Depth First Search) for Graph Traversal in Python

DFS is another very common graph traversal and searching algorithm. DFS uses backtracking to traverse the nodes in a graph. DFS tries to go far away from the start node until it reaches a dead node or leaf node. Then it uses backtrack to get back until it has new node to visit. Unlike BFS […]

## Basics of Graphs in Python

A graph contains vertices and edges. Vertices are also known as Nodes. Vertices in a graph is connected with each other through edges represented by a line. Not all the vertices in a graph need to be connected with each other. If the edges between the vertices are undirected, the graph is called an undirected […]