ajout: Implémentation de Path#isValid
This commit is contained in:
parent
c28ce560cf
commit
67cd79287d
1 changed files with 21 additions and 3 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue