From f7280fd82a6f4052fd9817ab9d03f9ff52cca2e2 Mon Sep 17 00:00:00 2001
From: p-hamann <p.hamann@dareit.de>
Date: Mon, 20 May 2019 12:12:51 +0200
Subject: [PATCH] Add IBFS test cases

---
 test/incremental_bfs_test.cpp | 48 +++++++++++++++++++++++++++++++++++
 test/meson.build              |  3 +++
 2 files changed, 51 insertions(+)
 create mode 100644 test/incremental_bfs_test.cpp

diff --git a/test/incremental_bfs_test.cpp b/test/incremental_bfs_test.cpp
new file mode 100644
index 0000000..3afa759
--- /dev/null
+++ b/test/incremental_bfs_test.cpp
@@ -0,0 +1,48 @@
+#include <vector>
+
+#include <catch2/catch.hpp>
+
+#include <gp-bnb/incremental_bfs.hpp>
+#include <gp-bnb/graph.hpp>
+#include <gp-bnb/metis_reader.hpp>
+
+// Tests for Incremental BFS Max Flow algorithm
+
+TEST_CASE("IncrementalBFSMaxFlow") {
+    
+    std::vector<std::vector<node_id>> adjacency_list {
+        { 2, 7 },           // 1
+        { 1, 3, 4 },        // 2
+        { 2, 5 },           // 3
+        { 2, 5 },           // 4
+        { 3, 4, 6},         // 5
+        { 5, 8 },           // 6
+        { 1, 8 },           // 7
+        { 6, 7 }            // 8
+    };
+
+    graph g (adjacency_list) ;
+
+    std::vector<node_id> sources { 1 };
+    std::vector<node_id> sinks { 8 };
+    incremental_bfs ibfs = incremental_bfs(g, sources, sinks);
+
+    ibfs.run();
+    int max_flow = ibfs.get_max_flow();
+
+    REQUIRE(max_flow == 2);
+
+    std::string graph_file = "../test/inputs/tiny_01.graph";
+    graph g2 = metis_reader().read(graph_file);
+    
+    std::vector<node_id> sources2 { 1 };
+    std::vector<node_id> sinks2 { 7 };
+
+    incremental_bfs ibfs2 = incremental_bfs(g2, sources2, sinks2);
+
+    ibfs2.run();
+    int max_flow2 = ibfs2.get_max_flow();
+
+    REQUIRE(max_flow2 == 2);
+
+}
diff --git a/test/meson.build b/test/meson.build
index 819d301..f7c8829 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -3,11 +3,14 @@ testexe = executable(
     'graph_test.cpp',
     'reader_test.cpp',
     'edmonds_karp_test.cpp',
+    'incremental_bfs_test.cpp',
     'bnb_test.cpp', # tests source files to be compiled
     '../bnb/graph.cpp',
 	'../bnb/partition.cpp',
 	'../bnb/metis_reader.cpp',
     '../bnb/edmonds_karp.cpp',
+    '../bnb/incremental_bfs.cpp',
+    '../bnb/ibfs_subtree.cpp',
 	'../bnb/bnb.cpp',
     include_directories : inc)  # declared include directories in root :code:`meson.build`
 
-- 
GitLab