মডিউল ৫_৩ঃ Cycle Detection Undirected গ্রাফ DFS ইমপ্লিমেন্টশন
Cycle Detection Undirected গ্রাফ DFS ইমপ্লিমেন্টশন
int n, e;
cin >> n >> e;
while (e--)
{
int a, b;
cin >> a >> b;
adj[a].push_back(b);
adj[b].push_back(a);
}memset(vis, false, sizeof(vis));
memset(parentArray, -1, sizeof(parentArray));
ans = false;for (int i = 0; i < n; i++)
{
if (!vis[i])
{
dfs(i);
}
}সম্পূর্ণ কোড Cycle Detection Undirected গ্রাফ DFS ইমপ্লিমেন্টশন
Previousমডিউল ৫_২ঃ Cycle Detection Undirected গ্রাফ BFS ইমপ্লিমেন্টশনNextমডিউল ৫_৪ঃ Cycle Detection Directed গ্রাফে
Last updated