milieu séance
This commit is contained in:
parent
8ab68ac6e7
commit
93fbf88d99
1 changed files with 42 additions and 11 deletions
|
@ -51,12 +51,34 @@ public class Path {
|
||||||
* @throws IllegalArgumentException If the list of nodes is not valid, i.e. two
|
* @throws IllegalArgumentException If the list of nodes is not valid, i.e. two
|
||||||
* consecutive nodes in the list are not connected in the graph.
|
* consecutive nodes in the list are not connected in the graph.
|
||||||
*
|
*
|
||||||
* @deprecated Need to be implemented.
|
|
||||||
*/
|
*/
|
||||||
public static Path createShortestPathFromNodes(Graph graph, List<Node> nodes)
|
public static Path createShortestPathFromNodes(Graph graph, List<Node> nodes)
|
||||||
throws IllegalArgumentException {
|
throws IllegalArgumentException {
|
||||||
List<Arc> arcs = new ArrayList<Arc>();
|
List<Arc> arcs = new ArrayList<Arc>();
|
||||||
// TODO:
|
boolean suiv;
|
||||||
|
Arc bonarc;
|
||||||
|
|
||||||
|
for (int i=0;i<nodes.size()-1;i++) {
|
||||||
|
|
||||||
|
if (nodes.get(i).getNumberOfSuccessors()<=0)
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
|
||||||
|
bonarc=Node.linkNodes(null, null, Float.MAX_VALUE, null, null);
|
||||||
|
|
||||||
|
for (int parcourt=0; parcourt<nodes.get(i).getNumberOfSuccessors(); parcourt++) {
|
||||||
|
suiv=false;
|
||||||
|
if (nodes.get(i).getSuccessors().get(parcourt).getDestination()==nodes.get(i+1)) {
|
||||||
|
|
||||||
|
if (nodes.get(i).getSuccessors().get(parcourt).getLength()<bonarc.getLength()) {
|
||||||
|
bonarc=nodes.get(i).getSuccessors().get(parcourt);
|
||||||
|
suiv=true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!suiv)
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
|
arcs.add(bonarc);
|
||||||
|
}
|
||||||
return new Path(graph, arcs);
|
return new Path(graph, arcs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,11 +220,20 @@ public class Path {
|
||||||
*
|
*
|
||||||
* @return true if the path is valid, false otherwise.
|
* @return true if the path is valid, false otherwise.
|
||||||
*
|
*
|
||||||
* @deprecated Need to be implemented.
|
|
||||||
*/
|
*/
|
||||||
public boolean isValid() {
|
public boolean isValid() {
|
||||||
// TODO:
|
boolean bool=true;
|
||||||
return false;
|
if (!this.isEmpty() && !this.arcs.isEmpty()) {
|
||||||
|
if (this.origin!=this.arcs.get(0).getOrigin())
|
||||||
|
bool=false;
|
||||||
|
else if (this.arcs.size()>1) {
|
||||||
|
for (int i=0;i<this.arcs.size()-1;i++) {
|
||||||
|
if (this.arcs.get(i).getDestination()!=this.arcs.get(i+1).getOrigin())
|
||||||
|
bool=false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -227,11 +258,9 @@ public class Path {
|
||||||
* @return Time (in seconds) required to travel this path at the given speed (in
|
* @return Time (in seconds) required to travel this path at the given speed (in
|
||||||
* kilometers-per-hour).
|
* kilometers-per-hour).
|
||||||
*
|
*
|
||||||
* @deprecated Need to be implemented.
|
|
||||||
*/
|
*/
|
||||||
public double getTravelTime(double speed) {
|
public double getTravelTime(double speed) {
|
||||||
// TODO:
|
return this.getLength()*3.6/speed;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -240,11 +269,13 @@ public class Path {
|
||||||
*
|
*
|
||||||
* @return Minimum travel time to travel this path (in seconds).
|
* @return Minimum travel time to travel this path (in seconds).
|
||||||
*
|
*
|
||||||
* @deprecated Need to be implemented.
|
|
||||||
*/
|
*/
|
||||||
public double getMinimumTravelTime() {
|
public double getMinimumTravelTime() {
|
||||||
// TODO:
|
double temps=0.0;
|
||||||
return 0;
|
for (int i=0;i<this.arcs.size();i++) {
|
||||||
|
temps+=this.arcs.get(i).getMinimumTravelTime();
|
||||||
|
}
|
||||||
|
return temps;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue