ajout isEqual
This commit is contained in:
parent
8e44b2daf6
commit
f1d199a1ea
1 changed files with 29 additions and 7 deletions
|
@ -1,8 +1,7 @@
|
|||
package org.insa.graphs.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.awt.RenderingHints;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
|
@ -48,7 +47,10 @@ public class Path {
|
|||
public static Path createShortestPathFromNodes(Graph graph, List<Node> nodes)
|
||||
throws IllegalArgumentException {
|
||||
List<Arc> arcs = new ArrayList<Arc>();
|
||||
// TODO:
|
||||
// TODO: en fonction des mètres
|
||||
Boolean fini = false;
|
||||
|
||||
|
||||
return new Path(graph, arcs);
|
||||
}
|
||||
|
||||
|
@ -184,11 +186,31 @@ public class Path {
|
|||
* </ul>
|
||||
*
|
||||
* @return true if the path is valid, false otherwise.
|
||||
* @deprecated Need to be implemented.
|
||||
*/
|
||||
public boolean isValid() {
|
||||
// TODO:
|
||||
return false;
|
||||
|
||||
if (this.isEmpty()) {// Vérifie si le path est vide
|
||||
return true;
|
||||
}
|
||||
|
||||
if (this.arcs.isEmpty()) {// Vérifie si la liste d'arcs est vide
|
||||
return true;
|
||||
}
|
||||
|
||||
// Vérifie que le premier arc a pour origine le point de départ de la path
|
||||
if (!this.origin.equals(this.arcs.get(0).getOrigin())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Vérifie la continuité entre les arcs
|
||||
for (int i = 0; i < this.arcs.size() - 1; i++) {
|
||||
if (!this.arcs.get(i).getDestination()
|
||||
.equals(this.arcs.get(i + 1).getOrigin())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue