I have a function with the following header:
def DFS(G,s,n):
G: Graph to walk.
s: Node source or parent node.
n: Number of nodes for the cycle.
Input: We will pass to the function a graph G, a node 's' from where our dfs search will begin, and a number 'n'.
During our DFS journey, we have to detect how many cycles there are that contain 'n' nodes. For example:
If we have this graph and we have input
def DFS(G,1,5):
I should return:
[a, g, f, c, b] or [e, b, g, c, f]
Among other cycles that may be given that contain 'n' (5) nodes in this case within the graph.
Any ideas on how to implement this using DFS?
Thanks in advance.