aboutsummaryrefslogtreecommitdiff
path: root/LoopDetection.h
diff options
context:
space:
mode:
Diffstat (limited to 'LoopDetection.h')
-rw-r--r--LoopDetection.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/LoopDetection.h b/LoopDetection.h
new file mode 100644
index 0000000..f12c83b
--- /dev/null
+++ b/LoopDetection.h
@@ -0,0 +1,20 @@
+#pragma once
+
+#include <vector>
+#include <string>
+#include <unordered_set>
+#include <unordered_map>
+
+class LoopDetection {
+public:
+ LoopDetection() = default;
+ virtual ~LoopDetection();
+
+ virtual void add_connection(const std::string &src, const std::vector<std::string> &dests);
+
+private:
+ std::unordered_map<std::string, std::vector<std::string>> adj_list;
+
+ virtual bool detect_cycle(const std::string &start);
+ virtual bool is_cyclic(const std::string &node, std::unordered_set<std::string> &visited, std::unordered_set<std::string> &rec_stack);
+};