diff --git a/deferred_planarity_test/include/mps.h b/deferred_planarity_test/include/mps.h index 899e624..42b2896 100644 --- a/deferred_planarity_test/include/mps.h +++ b/deferred_planarity_test/include/mps.h @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include diff --git a/deferred_planarity_test/src/main.cpp b/deferred_planarity_test/src/main.cpp index 5a6c3d1..d7d1276 100644 --- a/deferred_planarity_test/src/main.cpp +++ b/deferred_planarity_test/src/main.cpp @@ -27,7 +27,7 @@ vector generate_mutated_post_order(const ogdf::Graph &G, vector post_o vector generate_guided_post_order(const ogdf::Graph &G, vector post_order); void vector_printer(const vector& state) { - for (int i = 0; i < static_cast(state.size()); ++i) { + for (size_t i = 0; i < state.size(); ++i) { std::cout << state[i] << ","; } std::cout << std::endl; @@ -49,20 +49,20 @@ vector repeated_mutation(const ogdf::Graph &G, int k_max, int mutate_point) // mutation produces rotated view // state_new = generate_mutated_post_order(G, state_old, mutate_point); // simulate a mutation - state_new = generate_guided_post_order(G, state_old); + // state_new = generate_guided_post_order(G, state_old); // another round of guided post order gives canonical representation - state_new = generate_guided_post_order(G, state_new); - new_edge_size = compute_removed_edge_size(G, state_new); + // state_new = generate_guided_post_order(G, state_new); + new_edge_size = compute_removed_edge_size(G, state_old); - if (new_edge_size < old_edge_size) { - state_old = state_new; - } + // if (new_edge_size < old_edge_size) { + // state_old = state_new; + // } } - vector_printer(state_new); - return state_new; + // vector_printer(state_new); + return state_old; } void test_correctness(const ogdf::Graph &G) { diff --git a/deferred_planarity_test/src/mps.cpp b/deferred_planarity_test/src/mps.cpp index 9df00be..9561122 100644 --- a/deferred_planarity_test/src/mps.cpp +++ b/deferred_planarity_test/src/mps.cpp @@ -59,18 +59,20 @@ maximal_planar_subgraph_finder::guidedPostOrderTraversal(vector post_order) // int start = rev_post_order[0]; + // implementation 2: use unordered_map to map node_id to position in reversed post_order unordered_map node_id_to_pos; int j = 0; // we flip the post_order vector around - for (size_t i = post_order.size() - 1; i >= 0; --i) { + for (size_t i = post_order.size() - 1; i != std::numeric_limits::max(); --i) { node_id_to_pos[post_order[i]] = j++; } + int postOrderID = 0; int end_condition = _node_list.size(); // we start from the end of the post_order, which is the root node int start = post_order[post_order.size() - 1]; int i = start; - + while (true) { if (((start > 0) && (i == (start - 1))) || ((start == 0 ) && (i == end_condition - 1))) diff --git a/deferred_planarity_test/src/mps_test.cpp b/deferred_planarity_test/src/mps_test.cpp index e3081c9..c1625f2 100644 --- a/deferred_planarity_test/src/mps_test.cpp +++ b/deferred_planarity_test/src/mps_test.cpp @@ -8,8 +8,7 @@ #include // #define DEBUG - -#define TIME +// #define TIME //----------------------------------------------------------------------------------- // Finding MPS @@ -138,14 +137,29 @@ int maximal_planar_subgraph_finder::compute_removed_edge_size(const ogdf::Graph start = std::chrono::high_resolution_clock::now(); #endif sort_adj_list(); + #ifdef TIME + end = std::chrono::high_resolution_clock::now(); + std::cout << "sort_adj_list: " << std::chrono::duration_cast(end - start).count() << std::endl; + #endif + + #ifdef TIME + start = std::chrono::high_resolution_clock::now(); + #endif determine_edges(); + #ifdef TIME + end = std::chrono::high_resolution_clock::now(); + std::cout << "determine edges: " << std::chrono::duration_cast(end - start).count() << std::endl; + #endif + + #ifdef TIME + start = std::chrono::high_resolution_clock::now(); + #endif back_edge_traversal(); #ifdef TIME end = std::chrono::high_resolution_clock::now(); - std::cout << "remaining procedures: " << std::chrono::duration_cast(end - start).count() << std::endl; + std::cout << "back edge traversal: " << std::chrono::duration_cast(end - start).count() << std::endl; #endif - return output_removed_edge_size(); } diff --git a/deferred_planarity_test/src/node.cpp b/deferred_planarity_test/src/node.cpp index 1db37a1..45c89d7 100644 --- a/deferred_planarity_test/src/node.cpp +++ b/deferred_planarity_test/src/node.cpp @@ -5,7 +5,7 @@ #include "mps.h" // #define DEBUG -#define DEBUG_MUTATION +// #define DEBUG_MUTATION //----------------------------------------------------------------------------------- // CONSTRUCTOR