diff --git a/src/main.rs b/src/main.rs index bff4b7a..6768cac 100644 --- a/src/main.rs +++ b/src/main.rs @@ -33,16 +33,17 @@ impl Graph { // TODO: 'fn are_adjacent()' could probably be done with a neighbor vertex iterator. fn are_adjacent(&self, v1: Vertex, v2: Vertex) -> bool { - let Some(next) = self.vertex_incidence_headers[v1.0].first_incidence else { + let Some(mut incidence) = self.vertex_incidence_headers[v1.0].first_incidence else { return false; }; loop { - if self.incidence_vertices[next.0] == v2 { + if self.incidence_vertices[incidence.0] == v2 { return true; } - let Some(next) = self.next_incidences[next.0] else { + let Some(next) = self.next_incidences[incidence.0] else { return false; }; + incidence = next; } }