From 67cd79287d9867e62f0e7357dad5b5fd5f125f87 Mon Sep 17 00:00:00 2001 From: Brendan Saint-Germes Date: Fri, 10 Apr 2026 14:14:12 +0200 Subject: [PATCH] =?UTF-8?q?ajout:=20Impl=C3=A9mentation=20de=20Path#isVali?= =?UTF-8?q?d?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/org/insa/graphs/model/Path.java | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/be-graphes-model/src/main/java/org/insa/graphs/model/Path.java b/be-graphes-model/src/main/java/org/insa/graphs/model/Path.java index 7580981..3cce7cf 100644 --- a/be-graphes-model/src/main/java/org/insa/graphs/model/Path.java +++ b/be-graphes-model/src/main/java/org/insa/graphs/model/Path.java @@ -184,11 +184,29 @@ public class Path { * * * @return true if the path is valid, false otherwise. - * @deprecated Need to be implemented. */ public boolean isValid() { - // TODO: - return false; + // size() == 0 <=> empty + // size() == 1 <=> single node (without arcs) + boolean result = false; + if (this.size() <= 1) { + result = true; + } else { + if (this.arcs.get(0).getOrigin() == this.origin) { + Arc prev = null; + result = true; + for (Arc next : this.arcs) { + if (prev != null) { + if (prev.getDestination() != next.getOrigin()) { + result = false; + break; + } + } + prev = next; + } + } + } + return result; } /**