Fixato bug e implementato alcune funzioni.

This commit is contained in:
2014-06-01 18:16:43 +02:00
parent 015d8cac76
commit e53f98a3a8
31 changed files with 910 additions and 151 deletions

View File

@@ -9,7 +9,7 @@ import arraylist.IndexList;
import position.NodePositionList;
import position.PositionList;
import java.security.InvalidKeyException;
import exceptions.InvalidKeyException;
public abstract class BFS<V, E, I, R> {
protected Graph<V, E> graph;

View File

@@ -2,7 +2,7 @@
package graph;
import java.security.InvalidKeyException;
import exceptions.InvalidKeyException;
public class ComponentsBFS<V, E> extends BFS<V, E, Object, Integer> {
protected Integer compNumber;
@@ -13,16 +13,11 @@ public class ComponentsBFS<V, E> extends BFS<V, E, Object, Integer> {
}
protected void startVisit(Vertex<V> v) {
try {
v.put(COMPONENT, compNumber);
}
catch (InvalidKeyException e){
}
}
protected Integer finalResult(Integer bfsResult) {
try {
for(Vertex<V> v : graph.vertices())
if(!isVisited(v)) {
compNumber++;
@@ -30,10 +25,5 @@ public class ComponentsBFS<V, E> extends BFS<V, E, Object, Integer> {
}
return compNumber;
}
catch (InvalidKeyException e){
}
return null;
}
}

View File

@@ -2,7 +2,7 @@ package graph;
//begin#fragment CC
import java.security.InvalidKeyException;
import exceptions.InvalidKeyException;
/** This class extends DFS to compute the connected components of a graph. */
public class ComponentsDFS<V, E> extends DFS<V, E, Object, Integer> {

View File

@@ -1,7 +1,7 @@
package graph;
import java.security.InvalidKeyException;
import exceptions.InvalidKeyException;
/** Generic DFS traversal of a graph using the template method pattern.
* Parameterized types: