diff --git a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/utils/BinaryHeap.java b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/utils/BinaryHeap.java index 2c1a239..1e4ce90 100644 --- a/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/utils/BinaryHeap.java +++ b/be-graphes-algos/src/main/java/org/insa/graphs/algorithm/utils/BinaryHeap.java @@ -134,11 +134,38 @@ public class BinaryHeap> implements PriorityQueue { this.arraySet(index, x); this.percolateUp(index); } - + @Override public void remove(E x) throws ElementNotFoundException { - // TODO: + int i; + E lastE; + boolean notFound = true; + for(i = 0; i< this.currentSize; i++) + { + if(array.get(i).equals(x)) + { + lastE = array.get(--currentSize); + this.arraySet(i, lastE); + notFound = false; + if(lastE.compareTo(x)>0) + { + percolateDown(i); + } + else + { + percolateUp(i); + } + break; + } + } + if(notFound) + { + throw new ElementNotFoundException(x); + } } + + + @Override public E findMin() throws EmptyPriorityQueueException { diff --git a/be-graphes-model/src/main/java/org/insa/graphs/model/Path.java b/be-graphes-model/src/main/java/org/insa/graphs/model/Path.java index c52868e..4559902 100644 --- a/be-graphes-model/src/main/java/org/insa/graphs/model/Path.java +++ b/be-graphes-model/src/main/java/org/insa/graphs/model/Path.java @@ -30,7 +30,6 @@ public class Path { * @throws IllegalArgumentException If the list of nodes is not valid, i.e. two * consecutive nodes in the list are not connected in the graph. * - * @deprecated Need to be implemented. */ public static Path createFastestPathFromNodes(Graph graph, List nodes) throws IllegalArgumentException { @@ -86,7 +85,6 @@ public class Path { * @throws IllegalArgumentException If the list of nodes is not valid, i.e. two * consecutive nodes in the list are not connected in the graph. * - * @deprecated Need to be implemented. */ public static Path createShortestPathFromNodes(Graph graph, List nodes) throws IllegalArgumentException { @@ -267,7 +265,6 @@ public class Path { * * @return true if the path is valid, false otherwise. * - * @deprecated Need to be implemented. */ public boolean isValid() {