DFS/BFS Graph Search with C#

This is a basic implementation of DFS/BFS graph search with C#. I have not seen many implementations in C# (most educational ones use Java) utilizing the .NET built-in data structures (Stack vs. Queue).

The search method returns a list corresponding to a path in order. The sample dataset is setup to illustrate the different results: BFS will always return the shortest path.

Code: https://dotnetfiddle.net/HCR4O8

One thought on “DFS/BFS Graph Search with C#

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s