ajout isEqual

This commit is contained in:
Bezza Younes 2025-04-04 10:12:29 +02:00
parent 8e44b2daf6
commit f1d199a1ea

View file

@ -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,11 +186,31 @@ 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()) {// 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;
} }
/** /**