static void Main(string[] args) { var verticesList = new VerticesList { new Vertex("A"), new Vertex("B"), new Vertex("C"), new Vertex("D"), new Vertex("E") }; var aAdjacencyLinkedList = new LinkedList(); aAdjacencyLinkedList.AddNode(new Node("B", 2)); aAdjacencyLinkedList.AddNode(new Node("E", 1)); verticesList[0].AdjacencyLinkedList = aAdjacencyLinkedList; var bAdjacencyLinkedList = new LinkedList(); bAdjacencyLinkedList.AddNode(new Node("A", 2)); bAdjacencyLinkedList.AddNode(new Node("C", 3)); verticesList[1].AdjacencyLinkedList = bAdjacencyLinkedList; var cAdjacencyLinkedList = new LinkedList(); cAdjacencyLinkedList.AddNode(new Node("D", 4)); cAdjacencyLinkedList.AddNode(new Node("E", 5)); verticesList[2].AdjacencyLinkedList = cAdjacencyLinkedList; var dAdjacencyLinkedList = new LinkedList(); verticesList[3].AdjacencyLinkedList = dAdjacencyLinkedList; var eAdjacencyLinkedList = new LinkedList(); eAdjacencyLinkedList.AddNode(new Node("A", 1)); verticesList[4].AdjacencyLinkedList = eAdjacencyLinkedList; foreach (var vertex in verticesList) { Console.WriteLine(); Console.WriteLine("Edge Name: {0}, Connected with: ", vertex.Name); vertex.AdjacencyLinkedList.PrintList(); } verticesList.DepthFirstTraversal(); Console.ReadKey(); }
public DijkstraShortestPath(VerticesList verticesList) { VerticesList = verticesList; InitVisitedAndShortestPathList(); }