Finding: backedge reuse from the head of DFS tree doesn't work
This commit is contained in:
parent
be49c6cfe0
commit
6c14e739ae
|
@ -162,7 +162,7 @@ public:
|
|||
~maximal_planar_subgraph_finder();
|
||||
int find_mps(string input_file);
|
||||
int compute_removed_edge_size(string input_file, vector<int> post_order, int mutate_point);
|
||||
void print_removed_edge_size(string input_file, vector<int> post_order, int mutate_point);
|
||||
void print_removed_edge_stats(string input_file, vector<int> post_order, int mutate_point);
|
||||
vector<int> generate_post_order(string input_file);
|
||||
vector<int> generate_guided_post_order(string input_file, vector<int> post_order);
|
||||
vector<int> generate_mutated_post_order(string input_file, vector<int> post_order, int mutate_point);
|
||||
|
@ -170,7 +170,7 @@ public:
|
|||
int get_mutate_point();
|
||||
node* get_new_node(node_type t);
|
||||
void read_from_gml(string input_file);
|
||||
void output_print_removed_edge_size();
|
||||
void output_print_removed_edge_stats();
|
||||
int output_int_removed_edge_size();
|
||||
vector<int> return_post_order();
|
||||
void postOrderTraversal();
|
||||
|
|
|
@ -31,4 +31,4 @@ $(BIN_DIR) $(OBJ_DIR):
|
|||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -r $(BIN_DIR) $(OBJ_DIR)
|
||||
rm -r $(OBJ_DIR)
|
||||
|
|
|
@ -15,55 +15,51 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
|
||||
// functions defined in mps_test.cpp
|
||||
int compute_removed_edge_size(string input_file, vector<int> post_order, int mutate_point);
|
||||
|
||||
void print_removed_edge_size(string input_file, vector<int> post_order, int mutate_point);
|
||||
|
||||
void print_removed_edge_stats(string input_file, vector<int> post_order, int mutate_point);
|
||||
vector<int> generate_post_order(string input_file);
|
||||
|
||||
vector<int> generate_guided_post_order(string input_file, vector<int> post_order);
|
||||
|
||||
vector<int> generate_mutated_post_order_at_x(string input_file, vector<int> post_order, int mutate_point);
|
||||
|
||||
|
||||
void vector_printer(vector<int> state) {
|
||||
for (int i = 0; i < state.size(); ++i) {
|
||||
std::cout << state[i] << ",";
|
||||
}
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void measure_removed_edges(string input_file, int k_max, int mutate_point) {
|
||||
// generate first state
|
||||
vector<int> state_old = generate_post_order(input_file);
|
||||
vector<int> state_new;
|
||||
|
||||
// std::cout << "first generated order" << std::endl;
|
||||
// for (int i = 0; i < state_old.size(); i++) {
|
||||
// std::cout << state_old[i] << ", ";
|
||||
// }
|
||||
// std::cout << std::endl;
|
||||
|
||||
int removed_old = compute_removed_edge_size(input_file, state_old, mutate_point);
|
||||
int removed_new;
|
||||
|
||||
for (int k = 0; k < k_max; ++k) {
|
||||
// std::cout << std::endl;
|
||||
// std::cout << "new generated order" << std::endl;
|
||||
// rotate to prep for next run
|
||||
state_new = generate_guided_post_order(input_file, state_old);
|
||||
// rotate to prep for next run
|
||||
// tree produced should be the same as earlier given tree, except from the mutate point
|
||||
state_new = generate_mutated_post_order_at_x(input_file, state_new, mutate_point);
|
||||
// for (int i = 0; i < state_new.size(); i++) {
|
||||
// std::cout << state_new[i] << ", ";
|
||||
// }
|
||||
// std::cout << std::endl;
|
||||
std::cout << "first post order" << std::endl;
|
||||
vector_printer(state_old);
|
||||
|
||||
// rotate to prep for next run
|
||||
// run mutation on canonical representation directly
|
||||
state_new = generate_mutated_post_order_at_x(input_file, state_old, mutate_point);
|
||||
// rotate output of mutated state to canonical representation
|
||||
state_new = generate_guided_post_order(input_file, state_new);
|
||||
// tree produced should be the same as tree from mutation
|
||||
removed_new = compute_removed_edge_size(input_file, state_new, mutate_point);
|
||||
|
||||
std::cout << "mutated post order" << std::endl;
|
||||
vector_printer(state_new);
|
||||
|
||||
|
||||
// std::cout << "removed edges in old: " << removed_old << std::endl;
|
||||
// std::cout << "removed edges in new: " << removed_new << std::endl;
|
||||
print_removed_edge_size(input_file, state_new, mutate_point);
|
||||
|
||||
print_removed_edge_stats(input_file, state_new, mutate_point);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -188,7 +188,7 @@ maximal_planar_subgraph_finder::back_edge_traversal() {
|
|||
// post_order starts from the last leaf of the DFS tree
|
||||
// hence we start counting from the post_order last index
|
||||
int post_order_mutate_point = node_list_last_index - dfs_mutate_point;
|
||||
std::cout << "post_order_mutate_point: " << post_order_mutate_point << std::endl;
|
||||
// std::cout << "post_order_mutate_point: " << post_order_mutate_point << std::endl;
|
||||
// back_edge first node is higher than the second
|
||||
for (int i = 0; i < _back_edge_list.size(); ++i) {
|
||||
// current node is the lower
|
||||
|
@ -199,13 +199,16 @@ maximal_planar_subgraph_finder::back_edge_traversal() {
|
|||
if (!back_edge_traversal(current_node, i_node->post_order_index())) {
|
||||
// if current_node is higher than post_order_mutate_point
|
||||
// then it is the preserved section
|
||||
if (current_node->post_order_index() >= post_order_mutate_point) {
|
||||
if (current_node->post_order_index() > post_order_mutate_point) {
|
||||
std::cout << "(" << current_node->node_id() << "[" << current_node->post_order_index() << "]"
|
||||
<< "," << i_node->node_id() << "[" << i_node->post_order_index() << "]" << ") ";
|
||||
_is_back_edge_eliminate[i] = NON_MUTATED_REMOVE;
|
||||
} else {
|
||||
_is_back_edge_eliminate[i] = MUTATED_REMOVE;
|
||||
}
|
||||
}
|
||||
}
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
//sub-function for the for-loop of back_edge_traversal().
|
||||
|
|
|
@ -24,9 +24,9 @@ int compute_removed_edge_size(string input_file, vector<int> post_order, int mut
|
|||
return m.compute_removed_edge_size(input_file, post_order, mutate_point);
|
||||
}
|
||||
|
||||
void print_removed_edge_size(string input_file, vector<int> post_order, int mutate_point) {
|
||||
void print_removed_edge_stats(string input_file, vector<int> post_order, int mutate_point) {
|
||||
maximal_planar_subgraph_finder m;
|
||||
m.print_removed_edge_size(input_file, post_order, mutate_point);
|
||||
m.print_removed_edge_stats(input_file, post_order, mutate_point);
|
||||
}
|
||||
|
||||
vector<int> generate_post_order(string input_file) {
|
||||
|
@ -90,7 +90,7 @@ int maximal_planar_subgraph_finder::compute_removed_edge_size(string input_file,
|
|||
return output_int_removed_edge_size();
|
||||
}
|
||||
|
||||
void maximal_planar_subgraph_finder::print_removed_edge_size(string input_file, vector<int> post_order, int mutate_point) {
|
||||
void maximal_planar_subgraph_finder::print_removed_edge_stats(string input_file, vector<int> post_order, int mutate_point) {
|
||||
read_from_gml(input_file);
|
||||
set_mutate_point(mutate_point);
|
||||
guidedPostOrderTraversal(post_order);
|
||||
|
@ -98,7 +98,7 @@ void maximal_planar_subgraph_finder::print_removed_edge_size(string input_file,
|
|||
sort_adj_list();
|
||||
determine_edges();
|
||||
back_edge_traversal();
|
||||
output_print_removed_edge_size();
|
||||
output_print_removed_edge_stats();
|
||||
}
|
||||
|
||||
|
||||
|
@ -144,7 +144,7 @@ void maximal_planar_subgraph_finder::read_from_gml(string input_file) {
|
|||
|
||||
|
||||
// count the number of removed edges
|
||||
void maximal_planar_subgraph_finder::output_print_removed_edge_size() {
|
||||
void maximal_planar_subgraph_finder::output_print_removed_edge_stats() {
|
||||
int mutated_sum = 0;
|
||||
int preserved_sum = 0;
|
||||
|
||||
|
|
Loading…
Reference in New Issue