From 761920b2c0c73efbcb302cac1978d98ff54c61c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20M=C3=BCller?= Date: Sat, 25 Oct 2025 00:56:24 +0200 Subject: [PATCH] Update Graph::are_adjacent() to use neighbors() iterator --- src/models.rs | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/src/models.rs b/src/models.rs index 58e25b0..4b6148d 100644 --- a/src/models.rs +++ b/src/models.rs @@ -61,20 +61,8 @@ impl Graph { self.incidence_headers[v.0].incidence_count } - // TODO: 'fn are_adjacent()' could probably be done with a neighbor vertex iterator. pub fn are_adjacent(&self, v1: Vertex, v2: Vertex) -> bool { - let Some(mut incidence) = self.incidence_headers[v1.0].first_incidence else { - return false; - }; - loop { - if self.incidence_vertices[incidence.0] == v2 { - return true; - } - let Some(next) = self.next_incidences[incidence.0] else { - return false; - }; - incidence = next; - } + self.neighbors(v1).find(|&x| x == v2).is_some() } // TODO: 'fn add_vertex()' needs variants for custom vertex data.