Blog Posts tagged with 'graph'

Depth-First Search in Python - Recursive and Non-Recursive Programming

Earlier I showed how to do depth-first search in C# and breadth-first search in C#. In this article I want to show depth-first search in Python, using both a recursive and non-recursive solution, because I want to show an example of topological sorting of a directed acyclic graph and the algorithm is based on depth-first search. I am also actively learning Python and it is best that I write Python code daily as much as possible.

Read More

Breadth-First Search and Shortest Path in C# and .NET Core

A look at breadth-first search in C# for traversing graphs. Breadth-first search is very similar to depth-first search, except that it internally uses a Queue instead of a Stack when traversing the graph. In the case of an unweighted graph, breadth-first search can also find the shortest path between two vertices in a graph.

Read More

Depth-First Search Algorithm in C# and .NET Core

Program and use the depth-first search algorithm in C# and .NET Core to find all the vertices that can be reached in an undirected graph given a starting vertex. Depth-first search helps answer the question of connectivity, and is useful for mapping physical networks, web pages, social networks, etc. There are recursive and iterative versions of depth-first search, and this article will show the iterative version that requires an extra Stack Data Structure to maintain vertices visited.

Read More