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;
|
package org.insa.graphs.model;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.awt.RenderingHints;
|
||||||
import java.util.Collections;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -48,7 +47,10 @@ public class Path {
|
||||||
public static Path createShortestPathFromNodes(Graph graph, List<Node> nodes)
|
public static Path createShortestPathFromNodes(Graph graph, List<Node> nodes)
|
||||||
throws IllegalArgumentException {
|
throws IllegalArgumentException {
|
||||||
List<Arc> arcs = new ArrayList<Arc>();
|
List<Arc> arcs = new ArrayList<Arc>();
|
||||||
// TODO:
|
// TODO: en fonction des mètres
|
||||||
|
Boolean fini = false;
|
||||||
|
|
||||||
|
|
||||||
return new Path(graph, arcs);
|
return new Path(graph, arcs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,13 +186,33 @@ 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:
|
|
||||||
|
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;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compute the length of this path (in meters).
|
* Compute the length of this path (in meters).
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue