Compare commits

..

2 commits

View file

@ -56,7 +56,22 @@ public class Path {
public static Path createShortestPathFromNodes(Graph graph, List<Node> nodes)
throws IllegalArgumentException {
List<Arc> arcs = new ArrayList<Arc>();
// TODO:
Arc candidat = null;
Node deb = nodes.remove(0);
for(Node fin : nodes){
float dist = Float.MAX_VALUE;
for(Arc a : deb.getSuccessors()){
if(a.getDestination().equals(fin)&&dist>a.getLength()){
dist = a.getLength();
candidat=a;
}
}
if(dist==Float.MAX_VALUE){
throw new IllegalArgumentException("Liste de noeuds non valide");
}
arcs.add(candidat);
deb = fin;
}
return new Path(graph, arcs);
}
@ -175,7 +190,7 @@ public class Path {
return this.origin == null;
}
/**
/**speed
* Get the number of <b>nodes</b> in this path.
*
* @return Number of nodes in this path.
@ -249,8 +264,11 @@ public class Path {
* @deprecated Need to be implemented.
*/
public double getTravelTime(double speed) {
// TODO:
return 0;
float res = 0;
for(Arc a : arcs){
res+=a.getTravelTime(speed);
}
return res;
}
/**