ADDED isvalid() gettraveltime() getminimumtraveltime()
This commit is contained in:
parent
41a7ead4b5
commit
cab5bb631d
1 changed files with 29 additions and 6 deletions
|
|
@ -34,6 +34,8 @@ public class Path {
|
||||||
*/
|
*/
|
||||||
public static Path createFastestPathFromNodes(Graph graph, List<Node> nodes)
|
public static Path createFastestPathFromNodes(Graph graph, List<Node> nodes)
|
||||||
throws IllegalArgumentException {
|
throws IllegalArgumentException {
|
||||||
|
|
||||||
|
|
||||||
List<Arc> arcs = new ArrayList<Arc>();
|
List<Arc> arcs = new ArrayList<Arc>();
|
||||||
//TODO
|
//TODO
|
||||||
return new Path(graph, arcs);
|
return new Path(graph, arcs);
|
||||||
|
|
@ -201,8 +203,18 @@ public class Path {
|
||||||
* @deprecated Need to be implemented.
|
* @deprecated Need to be implemented.
|
||||||
*/
|
*/
|
||||||
public boolean isValid() {
|
public boolean isValid() {
|
||||||
// TODO:
|
//DONE:
|
||||||
return false;
|
if (isEmpty()) {return true;}
|
||||||
|
if (size()==1) {return true;}
|
||||||
|
if (size()>1) {
|
||||||
|
if (arcs.get(0).getOrigin()!=origin) {return false;}
|
||||||
|
for(int i=1; i<size()-1;i++)
|
||||||
|
{
|
||||||
|
if (arcs.get(i).getOrigin()!=arcs.get(i-1).getDestination()) {return false;}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -234,8 +246,15 @@ public class Path {
|
||||||
* @deprecated Need to be implemented.
|
* @deprecated Need to be implemented.
|
||||||
*/
|
*/
|
||||||
public double getTravelTime(double speed) {
|
public double getTravelTime(double speed) {
|
||||||
// TODO:
|
// DONE:
|
||||||
return 0;
|
float time = 0;
|
||||||
|
for (Arc arc : this.arcs) {
|
||||||
|
time += arc.getTravelTime(speed);
|
||||||
|
}
|
||||||
|
return time;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -247,8 +266,12 @@ public class Path {
|
||||||
* @deprecated Need to be implemented.
|
* @deprecated Need to be implemented.
|
||||||
*/
|
*/
|
||||||
public double getMinimumTravelTime() {
|
public double getMinimumTravelTime() {
|
||||||
// TODO:
|
// DONE:
|
||||||
return 0;
|
float time = 0;
|
||||||
|
for (Arc arc : this.arcs) {
|
||||||
|
time += arc.getTravelTime(arc.getRoadInformation().getMaximumSpeed());
|
||||||
|
}
|
||||||
|
return time;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue