algorithm - Count number of cycles in directed graph using DFS -
i want count total number of directed cycles available in directed graph (only count required).
you can assume graph given adjacency matrix.
i know dfs
not make working algorithm problem.
please provide pseudo code using dfs
.
let consider , coloring nodes 3 types of color . if node yet discovered color white . if node discovered of descendants is/are yet discovered color grey. otherwise color black . now, while doing dfs if face situation when, there edge between 2 grey nodes graph has cycle. total number of cycles total number of times face situation mentioned above i.e. find edge between 2 grey nodes .
Comments
Post a Comment