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 6ebdb73..6fd9edd 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 @@ -29,13 +29,47 @@ 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 { - List arcs = new ArrayList(); - // TODO: + + Arc currentArc = null; + + for(int i=0; i arcs = new ArrayList(); + double travelTime = 9999; + + if(nodes.size() == 0) { + return new Path(graph); + } + if(nodes.size() == 1) { + return new Path(graph, nodes.get(0) ); + } + + for(int i=0; i nodes) throws IllegalArgumentException { + + Arc currentArc = null; + + for(int i=0; i arcs = new ArrayList(); - // TODO: + float distanceMin = 9999; + + if(nodes.size() == 0) { + return new Path(graph); + } + if(nodes.size() == 1) { + return new Path(graph, nodes.get(0) ); + } + for(int i=0; i * * @return true if the path is valid, false otherwise. - * - * @deprecated Need to be implemented. */ public boolean isValid() { - // TODO: - return false; + if(this.isEmpty()) { + return true; + } + if(this.origin != null && this.arcs.isEmpty()) { + return true; + } + + if(!this.arcs.get(0).getOrigin().equals(this.getOrigin()) ) { + return false; + } + if(!this.arcs.get(this.arcs.size() -1 ).getDestination().equals(this.getDestination()) ) { + return false; + } + + for(int i=0;i