private void BFSTraversal(int start, VertexQue route, int destination) { /* make a queue of vertices */ var queue = new VertexQue(); /* make a mark set of vertices */ var visited = new VertexMarkSet(); /* enqueue and mark start */ queue.Enqueue(start); visited.Add(start); /* while the queue is not empty */ while (queue.NotEmpty()) { /* dequeue a vertext */ var departure = queue.Dequeue(); var stops = _graph.ListNeighbours(departure); foreach (int stop in stops) { /* enqueue and mark all the unmarked neighbours of the vertex */ if (!visited.Contains(stop)) { visited.Add(stop); queue.Enqueue(stop); } if (stop == destination) { route.Enqueue(stop); } } } }
private void DFSMax(int start, VertexQue trips, int destination) { // displaying current node var current_node = _graph.GetNodeName(start); // Fetching next stops var stops = _graph.ListNeighbours(start); foreach (int stop in stops) { if (stop == destination) { trips.Enqueue(stop); return; } DFSMax(stop, trips, destination); } }