MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / cycleDirectedDFS

Function cycleDirectedDFS

CPP/graphseries.cpp:135–156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

133}
134
135bool cycleDirectedDFS(int n, vector<int> &vis, vector<int> &dfsvis, vector<int> arr[])
136{
137 vis[n] = 1;
138 dfsvis[n] = 1;
139
140 for (auto i : arr[n])
141 {
142 if (vis[i] == 0)
143 {
144 if (cycleDirectedDFS(i, vis, dfsvis, arr))
145 return true;
146 }
147 else
148 {
149 if (dfsvis[i])
150 return true;
151 }
152 }
153
154 dfsvis[n] = 0;
155 return false;
156}
157
158void findTopoSortDFS(int node, vector<int> arr[], stack<int> &s, vector<int> &vis)
159{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected