Solution: Print the Transpose of a Graph
In this review lesson, we give a detailed analysis of how to transpose a graph.
We'll cover the following...
Solution: Traversal of Adjacency List
Press + to interact
main.cpp
Graph.cpp
Graph.h
#include<iostream>#include <list>#include <vector>using namespace std;class Graph {int vertices;list<int> *adjacencyList;public:Graph();Graph(int V);void addEdge(int v, int w);void getTranspose();void printGraph();};
This solution is pretty straight forward. Just make another graph, but start reversing it. Traverse the adjacency list of the given graph and—on encountering a vertex in the adjacency list of vertex ...