Compare commits

..

2 commits

Author SHA1 Message Date
alejeune
7fedb6de7a Merge branch 'master' of https://git.etud.insa-toulouse.fr/alejeune/BE_Graphe_alejeune_rlacroix
Travail a plusieurs, ajout des fonctions faites par Aurélia
2022-03-27 21:38:11 +02:00
alejeune
a8f7f4ed5a ajout des fonctions isValid et tempsMin 2022-03-27 21:37:35 +02:00

View file

@ -250,12 +250,39 @@ public class Path {
*
* @return true if the path is valid, false otherwise.
*
* @deprecated Need to be implemented.
*/
public boolean isValid() {
// TODO:
Arc old = null;
// it is empty
if (this.isEmpty()) {
return true;
}
// Origin is ok
if ((this.origin != null) && (this.arcs.size() == 0)) {
return true;
}
if (this.arcs.size() == 0) {
return false;
}
// destination of the first one is the origin of the second node
if (this.arcs.get(0).getOrigin() == this.origin) {
for (Arc a : this.arcs) {
if (this.arcs.get(0) == a) {
old = this.arcs.get(0);
}
else if (old.getDestination() == a.getOrigin()) {
old = a;
}
else {
return false;
}
}
return true;
}
else {
return false;
}
}
/**
* Compute the length of this path (in meters).
@ -265,7 +292,7 @@ public class Path {
*/
public float getLength() {
float acc = 0;
for (Arc l : arcs) {
for (Arc l : this.arcs) {
acc += l.getLength();
}
@ -292,11 +319,13 @@ public class Path {
*
* @return Minimum travel time to travel this path (in seconds).
*
* @deprecated Need to be implemented.
*/
public double getMinimumTravelTime() {
// TODO:
return 0;
float acc = 0;
for (Arc l : this.arcs) {
acc += l.getMinimumTravelTime();
}
return acc;
}
}