From 05ab338cf216ae109f50375bfba686d253db12e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ke=C3=9Fler?= Date: Sat, 4 Nov 2023 19:34:16 +0100 Subject: [PATCH] add some assertions --- graph.cpp | 2 ++ graph.hpp | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/graph.cpp b/graph.cpp index 5041d36..16b5710 100644 --- a/graph.cpp +++ b/graph.cpp @@ -23,6 +23,8 @@ */ #include +#include + // Anonymous name spaces may be used to show the reader // that a function will only be used in the current file. namespace diff --git a/graph.hpp b/graph.hpp index 5622327..8b71861 100644 --- a/graph.hpp +++ b/graph.hpp @@ -40,6 +40,7 @@ */ #include +#include /** * Namespaces can be used in order to make sure different modules, * possibly implemented by different people don't have classes/functions/... @@ -238,18 +239,21 @@ Node & Graph::node(NodeId const id) inline NodeId Graph::matched_neighbor(NodeId const id) const { + assert(id <= num_nodes()); return _nodes[id].matched_neighbor; } inline NodeId Graph::ear_or_root_neighbor(const ED::NodeId id) const { + assert(id <= num_nodes()); return _nodes[id].ear_or_root_neighbor; } inline NodeId Graph::root_of_ear_component(const ED::NodeId id) const { + assert(id <= num_nodes()); return _nodes[id].root_of_ear_component; }