O'Reilly logo

C# Data Structures and Algorithms by Marcin Jamro

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Example – undirected and unweighted edges

Let's try to use the previous implementation to create the undirected and unweighted graph, according to the following diagram:

As you can see, the graph contains 8 nodes and 10 edges. You can configure the example graph in the Main method in the Program class. The implementation starts with the following line of code, which initializes a new undirected graph (with false as the value of the first parameter) and an unweighted graph (with false as the value of the second parameter):

Graph<int> graph = new Graph<int>(false, false); 

Then, you add the necessary nodes, and store references to them as new ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required