-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstance.h
More file actions
80 lines (55 loc) · 1.42 KB
/
instance.h
File metadata and controls
80 lines (55 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#ifndef H_INSTANCE_
#define H_INSTANCE_
#include "tree_decomposition.h"
#include <algorithm>
#include <cassert>
#include <map>
#include <set>
#include <vector>
#include <iostream>
using namespace std;
struct Node {
int id;
bool terminal;
set<int> edges;
};
struct Edge {
int id;
int endpoints[2];
int weight;
};
struct DynamicGraph {
int next_node_id;
int next_edge_id;
map<int, Node> nodes;
map<int, Edge> edges;
DynamicGraph() : next_node_id(0), next_edge_id(0) {}
int createNode(bool terminal);
int createEdge(int a, int b, int w);
Edge removeEdge(int id);
void addEdge(Edge edge);
Node removeNode(int id);
void addNode(Node node);
int neighbour(int node, Edge& edge);
map<int, int> remapNodeIds();
vector<bool> getRemappedTerminals(const map<int, int>& new_node_id);
vector<vector<pair<int, int>>> getRemappedGraph(
const map<int, int>& new_node_id);
};
struct DynamicTreeDecomposition {
vector<set<int>> bags;
vector<vector<int>> tree;
struct ReplacementUndoData {
vector<pair<int, int>> add;
vector<pair<int, int>> remove;
};
ReplacementUndoData replaceNode(int a, int b);
void undoReplaceNode(const ReplacementUndoData& undo_data);
TreeDecomposition getRemappedTreeDecomposition(
const map<int, int>& new_node_id);
};
struct Instance {
DynamicGraph graph;
DynamicTreeDecomposition td;
};
#endif