0

SA : I ask if anyone can help me in this algorithm , it is suppose that this algorithm find all the cycles in given graph . but there exist a bug it return only one cycle not all :

```
public class Main {
public boolean funcs(boolean Graph[][]){
ArrayList<ArrayList<Integer>>l=new ArrayList<ArrayList<Integer>>();
ArrayList<Integer>c=new ArrayList<Integer>();
for (int i = 0; i < Graph.length; i++) {
for (int j = 0; j < Graph.length; j++) {
if (Graph[i][j]){
boolean vis []=new boolean [Graph.length];
boolean[][] Gcopy=Graph.clone();
ArrayList<Integer>cycle=new ArrayList<Integer>();
if (DFS(Gcopy, vis, i, j, cycle)){
cycle.add(i);
Graph[i][j]=false;
l.add(cycle);
}
}
}
}
System.out.println(l);
if (l.isEmpty())
return true;// e.g no cycle in the graph
return false;
}
public boolean DFS(boolean graph[][], boolean [] vis, int strtNode, int node , ArrayList<Integer> cycle){
if (node==strtNode)
return true;
if(vis[node])
return false;
vis[node]=true;
for (int i = 0; i < graph.length; i++) {
if(graph[node][i] )
{
if(DFS(graph,vis,strtNode,i,cycle))
{
cycle.add(node);
graph[node][i]=false;
return true;
}
}
}
return false;
}
public void parse (String transaction ){
String pros[]=transaction.split(",");
for (int i = 0; i < pros.length; i++)
pros[i]=pros[i].toUpperCase();
}
public static void main(String[] args) {
boolean [][]a={{false,true,false,false},{false,false,true,false},{true,false,false,true},{true,false,false,false}};
new Main().funcs(a);
}
}
```

the example in the main contain two cycles also it return only one .

please help urgent .