Implement a Weighted Graph in C++ with fundamental graph traversal and routing algorithms:
int numVertices.std::vector<std::vector<std::pair<int, int>>> adjList: Stores (destination, weight) pairs for each vertex.void addEdge(int u, int v, int weight, bool bidirectional = false): Adds weighted connection.void bfs(int startVertex) const: Breadth-First Search traversal using a queue.void dfs(int startVertex) const: Depth-First Search traversal using recursion.bool hasCycle() const: Detects cycles in graph.std::pair<int, std::vector<int>> dijkstra(int start, int target) const:std::priority_queue.start to target using a parent[] array.BFS Traversal starting from 0: 0 1 2 3 4 5 DFS Traversal starting from 0: 0 1 3 5 4 2 === Dijkstra Shortest Path (Node 0 to Node 5) === Shortest Distance from 0 to 5: 9 Optimal Route: 0 -> 1 -> 3 -> 5 [✓] Graph data structures & Dijkstra routing verified (Time: 0.009s, Memory: 2.3 MB)