April 2018
Intermediate to advanced
292 pages
6h 44m
English
To start with, let's take a look at the code of the generic class representing a single node in a graph. Such a class is named Node and its code is shown as follows:
public class Node<T>
{
public int Index { get; set; }
public T Data { get; set; }
public List<Node<T>> Neighbors { get; set; }
= new List<Node<T>>();
public List<int> Weights { get; set; } = new List<int>();
public override string ToString()
{
return $"Node with index {Index}: {Data},
neighbors: {Neighbors.Count}";
}
}
The class contains four properties. As all of these elements perform important roles in the code snippets shown in this chapter, let's analyze them in detail: