made isValid()
This commit is contained in:
parent
472b578692
commit
b65f6c27ca
1 changed files with 13 additions and 3 deletions
|
|
@ -184,11 +184,21 @@ public class Path {
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
* @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:
|
|
||||||
return false;
|
if (this.isEmpty()) { return true; }
|
||||||
|
if (this.size() == 1 && this.arcs.isEmpty()) { return true; }
|
||||||
|
if (this.arcs.get(0).getOrigin() != this.origin) { return false; }
|
||||||
|
|
||||||
|
Boolean good = true;
|
||||||
|
for (int i = 0; i < this.arcs.size() - 1; i++) {
|
||||||
|
if (this.arcs.get(i).getDestination() != this.arcs.get(i+1).getOrigin()) {
|
||||||
|
good = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return good;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue