4,370 views
1 votes
1 votes
The transpose of a directed graph $G=(V,E)$ is the graph $G^T=(V,E^T)$, where $E^T=\{(v,u) \in V * V :(u,v) \in E \ \}$ .Thus ,$G^T$ is $G$ with all its edges reversed . Describe efficient algorithms for computing $G^T$ from $G$,for both the adjacency list and adjacency matrix representations of $G$. Analyze the running times of your algorithms.

1 Answer

0 votes
0 votes

# adjacency-list :

O(V+E)…

Iterate all the nodes, for each node i, mark its adjacency-list as L, then add i to all the nodes in L ...

 

## adjacency-matrix :

O(V*V)...

Just transpose the matrix …

 

Related questions

0 votes
0 votes
1 answer
1
akash.dinkar12 asked Apr 7, 2019
1,247 views
Give an adjacency-list representation for a complete binary tree on $7$ vertices. Give an equivalent adjacency-matrix representation. Assume that vertices are numbered fr...
0 votes
0 votes
1 answer
2
akash.dinkar12 asked Apr 7, 2019
362 views
Given an adjacency-list representation of a directed graph, how long does it take to compute the out-degree of every vertex ? How long does it take to compute the in-degr...