-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDynamicGraph.h
88 lines (69 loc) · 2.02 KB
/
DynamicGraph.h
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
81
82
83
84
85
86
87
88
///////////////////////////////////////////////////////////////////////////////
/// VariableGraph.h
/// Depict a graph that can change dynamically!
///
/// @remarks <TODO: insert remarks here>
///
/// @author Yan Qi @date 6/13/2010
///
/// $Id: DynamicGraph.h 58 2010-08-19 07:11:58Z yan.qi.asu $
///
///////////////////////////////////////////////////////////////////////////////
#ifndef __DynamicGraph_h
#define __DynamicGraph_h
#include "Graph.h"
using namespace std;
class DynamicGraph : public Graph
{
set<int> m_stRemovedVertexIds;
set<pair<int,int> > m_stRemovedEdge;
public:
/*DynamicGraph(void){}*/
DynamicGraph(const string graph_file_name):Graph(graph_file_name){}
DynamicGraph(const Graph& rGraph):Graph(rGraph){}
~DynamicGraph(void){}
void remove_edge(const pair<int,int> edge)
{
//m_stRemovedEdge.erase(m_stRemovedEdge.find(edge));
m_stRemovedEdge.insert(edge);
}
void remove_vertex(const int vertex_id)
{
m_stRemovedVertexIds.insert(vertex_id);
}
void recover_removed_edges()
{
m_stRemovedEdge.clear();
}
void recover_removed_vertices()
{
m_stRemovedVertexIds.clear();
}
void recover_removed_edge(const pair<int,int> edge)
{
m_stRemovedEdge.erase(m_stRemovedEdge.find(edge));
}
void recover_removed_vertex(int vertex_id)
{
m_stRemovedVertexIds.erase(m_stRemovedVertexIds.find(vertex_id));
}
double get_edge_weight_of_graph(const BaseVertex* source, const BaseVertex* sink)
{
return Graph::get_edge_weight(source, sink);
}
BaseVertex* get_vertex(int id)
{
if (m_stRemovedVertexIds.find(id) != m_stRemovedVertexIds.end())
{
return NULL;
}else
{
return Graph::get_vertex(id);
}
}
void get_vertex_list(vector<BaseVertex*>& vertex_list);
virtual double get_edge_weight(const BaseVertex* source, const BaseVertex* sink);
virtual void get_adjacent_vertices(BaseVertex* vertex, set<BaseVertex*>& vertex_set);
virtual void get_precedent_vertices(BaseVertex* vertex, set<BaseVertex*>& vertex_set);
};
#endif