Feat: reworked node marking to use enums; removed _ref_mark
This commit is contained in:
parent
e35462ef2d
commit
0ea4da9f0d
|
@ -33,6 +33,12 @@ enum node_type {
|
|||
AE_VIRTUAL_ROOT = 3
|
||||
};
|
||||
|
||||
enum mark_type {
|
||||
UNMARKED = 0,
|
||||
MARKED = 1,
|
||||
RESERVED = 2,
|
||||
};
|
||||
|
||||
class node
|
||||
{
|
||||
public:
|
||||
|
@ -116,7 +122,6 @@ public:
|
|||
|
||||
//MARK
|
||||
void mark();
|
||||
static void init_mark();
|
||||
void un_mark();
|
||||
bool is_marked();
|
||||
|
||||
|
@ -146,8 +151,7 @@ private:
|
|||
vector<node*> _essential_list;
|
||||
|
||||
//Mark
|
||||
int _mark;
|
||||
static int _ref_mark;
|
||||
mark_type _mark;
|
||||
};
|
||||
|
||||
class maximal_planar_subgraph_finder
|
||||
|
|
|
@ -31,4 +31,4 @@ $(BIN_DIR) $(OBJ_DIR):
|
|||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -r $(BIN_DIR) $(OBJ_DIR)
|
||||
rm -r $(OBJ_DIR)
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
#include <vector>
|
||||
|
||||
#include <ogdf/fileformats/GraphIO.h>
|
||||
#define START_TEMP 100
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
|
|
@ -34,7 +34,13 @@ maximal_planar_subgraph_finder::return_post_order() {
|
|||
//Determine the post-order-list by a DFS-traversal.
|
||||
void
|
||||
maximal_planar_subgraph_finder::postOrderTraversal() {
|
||||
node::init_mark();
|
||||
// node::init_mark(); // set ref_mark
|
||||
|
||||
// print out the ref_mark
|
||||
// std::cout << "normal post order traversal" << std::endl;
|
||||
// std::cout << "the ref mark is initialized to be:" << std::endl;
|
||||
// _node_list[0]->print_ref_mark();
|
||||
|
||||
// always start with node 0
|
||||
int postOrderID = 0;
|
||||
for (int i = 0; i < _node_list.size(); ++i) {
|
||||
|
@ -50,7 +56,7 @@ maximal_planar_subgraph_finder::postOrderTraversal() {
|
|||
// return is by reference via _post_order_list
|
||||
void
|
||||
maximal_planar_subgraph_finder::guidedPostOrderTraversal(vector<int> post_order) {
|
||||
node::init_mark();
|
||||
// node::init_mark();
|
||||
|
||||
vector<int> rev_post_order;
|
||||
for (int i = post_order.size() - 1; i >= 0; --i) {
|
||||
|
@ -86,7 +92,7 @@ maximal_planar_subgraph_finder::guidedPostOrderTraversal(vector<int> post_order)
|
|||
// return is by reference via _post_order_list
|
||||
void
|
||||
maximal_planar_subgraph_finder::mutatedPostOrderTraversal(vector<int> post_order, int mutate_point) {
|
||||
node::init_mark();
|
||||
// node::init_mark();
|
||||
|
||||
vector<int> rev_post_order;
|
||||
for (int i = post_order.size() - 1; i >= 0; --i) {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include "mps.h"
|
||||
|
||||
// #define DEBUG
|
||||
#define DEBUG_MUTATION
|
||||
// #define DEBUG_MUTATION
|
||||
|
||||
//-----------------------------------------------------------------------------------
|
||||
// CONSTRUCTOR
|
||||
|
@ -20,7 +20,7 @@ node::node(node_type t) {
|
|||
_parent = 0;
|
||||
_post_order_index = INT_MAX;
|
||||
_node_id = INT_MAX;
|
||||
_mark = 0;
|
||||
_mark = UNMARKED;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------
|
||||
|
@ -57,7 +57,7 @@ node* node::adj(int i) {return _adj_list[i];}
|
|||
void node::set_adj_list(vector<node*> vec) {_adj_list = vec;}
|
||||
|
||||
void node::DFS_visit(vector<node*> &dfsList, int &index) {
|
||||
mark();
|
||||
mark(); // set _mark to _ref_mark
|
||||
for (int i = 0; i < _adj_list.size(); ++i) {
|
||||
if (!_adj_list[i]->is_marked()) {
|
||||
_adj_list[i]->_parent = this;
|
||||
|
@ -358,12 +358,8 @@ void node::add_essential(node* u) {_essential_list.push_back(u);}
|
|||
//-----------------------------------------------------------------------------------
|
||||
// MARK
|
||||
//-----------------------------------------------------------------------------------
|
||||
void node::mark() {_mark = _ref_mark;}
|
||||
void node::mark() {_mark = MARKED;}
|
||||
|
||||
void node::init_mark() {++_ref_mark;}
|
||||
void node::un_mark() {_mark = UNMARKED;}
|
||||
|
||||
void node::un_mark() {_mark = 0;}
|
||||
|
||||
bool node::is_marked() {return _mark == _ref_mark;}
|
||||
|
||||
int node::_ref_mark = 1;
|
||||
bool node::is_marked() {return _mark == MARKED;}
|
Loading…
Reference in New Issue