ajout: Implémentation de Path#isValid

This commit is contained in:
Brendan Saint Germes 2026-04-10 14:14:12 +02:00
parent c28ce560cf
commit 67cd79287d

View file

@ -184,11 +184,29 @@ public class Path {
* </ul>
*
* @return true if the path is valid, false otherwise.
* @deprecated Need to be implemented.
*/
public boolean isValid() {
// TODO:
return false;
// size() == 0 <=> empty
// size() == 1 <=> single node (without arcs)
boolean result = false;
if (this.size() <= 1) {
result = true;
} else {
if (this.arcs.get(0).getOrigin() == this.origin) {
Arc prev = null;
result = true;
for (Arc next : this.arcs) {
if (prev != null) {
if (prev.getDestination() != next.getOrigin()) {
result = false;
break;
}
}
prev = next;
}
}
}
return result;
}
/**