915 views
1 votes
1 votes
If the graph G(V,E) is represented using adjacency matrix then to find universal sink (in degree is V-1 and out degree is 0)

1 Answer

0 votes
0 votes
In a directed graph, G represented as E(u,v), where u->v is an edge in the graph. You can find your universal sink by the following algorithm :

-> Iterate over each edge E(u,v) belonging in the graph G. For each edge E(u,v) you visit, increment the in-degree for v by one.

-> Iterate on all vertexes, and check for the one with in-degree V-1.

After doing these 2 simple loops. You will have only one or no vertex with you.

In case you have no vertex with V-1 as in-degree, then there is no universal sink.

Else your have your universal sink.

Related questions

0 votes
0 votes
0 answers
2
Isha Gupta asked Jun 12, 2016
1,121 views
2 votes
2 votes
1 answer
3
1 votes
1 votes
1 answer
4