Fixato bug e implementato alcune funzioni.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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> {
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user