I found this algorithm for digraphs that checks whether a total sink exists in a graph. https://www.geeksforgeeks.org/determine-whether-universal-sink-exists-directed-graph/
My question is : Is this valid for a non - dag digraph?
Because if a cycle between v1, v2 exists then we may miss to identify this 1 and mistakenly think of v2 as a source sink (or am I missing something here)?


The algorithm will work correctly. You are missing the additional
is_sinkmethod.After
j == vertices, we make this check to ensure that there is indeed no cycle present in the graph which contains the vertexi.