Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A transportation network has 10 nodes. Distances between nodes are shown in Tabl

ID: 3827145 • Letter: A

Question

A transportation network has 10 nodes. Distances between nodes are shown in Table 1. Total five emergency vehicles are located at nodes 2, 4, 5, 7, and 9. There is one vehicle at each of these five nodes. The vehicles must travel to destination nodes 1, 3, 6, 8 and 10. Each destination node will have one vehicle. Suppose that emergency vehicles may travel along both directions of any road shown in Table 1. Please apply the Dijkstra's algorithm and Hungarian method to minimize the total travel distance of the five vehicles.

Explanation / Answer

#include #include using namespace std; // This class represents a directed graph using adjacency list representation class Graph { int V; // No. of vertices list *adj; // Pointer to an array containing adjacency lists public: Graph(int V); // Constructor void addEdge(int v, int w); // function to add an edge to graph bool isReachable(int s, int d); // returns true if there is a path from s to d }; Graph::Graph(int V) { this->V = V; adj = new list [V]; } void Graph::addEdge(int v, int w) { adj[v].push_back(w); // Add w to v’s list. } // A BFS based function to check whether d is reachable from s. bool Graph::isReachable(int s, int d) { // Base case if (s == d) return true; // Mark all the vertices as not visited bool *visited = new bool[V]; for (int i = 0; i u >> v; if (g.isReachable(u, v)) cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote