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;
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,13 +186,33 @@ public class Path {
* </ul>
*
* @return true if the path is valid, false otherwise.
* @deprecated Need to be implemented.
*/
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;
}
// 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).
*