Skip to content
Snippets Groups Projects
Commit 5fc36539 authored by Gianluca's avatar Gianluca
Browse files

es finito

parent e2d1dddb
No related branches found
No related tags found
No related merge requests found
......@@ -73,8 +73,7 @@ public class TestGraph {
void testForesta() {
GraphInterface grafo = new UndirectedGraph("5; 0 3; 0 4; 3 4; 1 2;");
DFS dfsTest = new DFS(grafo);
for (GraphInterface g : dfsTest.visitaDFSCompleta()) {
System.out.println(g);
}
GraphInterface forest = dfsTest.getForest();
Assertions.assertFalse(forest.hasEdge(0,1) || forest.hasEdge(3,1) || forest.hasEdge(4, 1) || forest.hasEdge(0,2) || forest.hasEdge(3,2) || forest.hasEdge(4, 2));
}
}
......@@ -41,13 +41,12 @@ public class DFS {
return this.treeDFS;
}
public ArrayList<GraphInterface> visitaDFSCompleta() {
ArrayList<GraphInterface> returnArray = new ArrayList<>();
public GraphInterface getForest() {
for (int nodo = 0; nodo < this.myGraph.getOrder(); nodo++) {
if (!this.scoperti[nodo]) {
returnArray.add(getTree(nodo));
getTree(nodo);
}
}
return returnArray;
return this.treeDFS;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment