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