Statistics
| Branch: | Revision:

root / custompackages / graph-parser / src / graph_manager.h @ cb770240

History | View | Annotate | Download (1.95 KB)

1
//
2
// Created by quynh on 1/15/15.
3
//
4

    
5
#ifndef GRAPH_PARSER_GRAPH_MANAGER_H
6
#define GRAPH_PARSER_GRAPH_MANAGER_H
7

    
8
#include "common.h"
9
#include "utility.h"
10

    
11
class GraphManager {
12
public:
13
    typedef boost::vertex_bundle_type<Graph>::type VertexProperties; // aka Router in common.h
14
    typedef boost::edge_bundle_type<Graph>::type EdgeProperties; // aka Link in common.h
15
    typedef std::map<std::string, Vertex> NameVertexMap;
16

    
17
    GraphManager(); // constructor
18
    GraphManager(const GraphManager& other); // copy constructor
19
    GraphManager& operator=(GraphManager& rhs); // assignment operator
20
    // check out more here: http://www.cplusplus.com/articles/y8hv0pDG/
21

    
22
    void AddEdge(VertexProperties vp1, VertexProperties vp2, EdgeProperties ep);
23
    bool vertex_existed(string s);
24
    const Vertex& get_vertex_from_id(string s);
25

    
26
    StringSet vertices_id();
27

    
28
    void ResetVerticesAndEdgesIndexMap();
29

    
30
    // Function to print results
31
    // TODO: checkout utility.h, I can't overload << operator to output
32
    // the correct result. Therefore, I use print() ufnction as a replacement.
33
    void print_v_index_map();
34
    void print_e_index_map();
35

    
36
    // Getter
37
    const VertexIndexMap& v_index_map() const;
38
    const EdgeIndexMap& e_index_map() const;
39

    
40
    // Output Operators
41
    friend std::ostream& operator<<(std::ostream& os, const GraphManager& gm);
42

    
43
    Graph g_;
44
private:
45
    void reset_v_id_vertex_map();
46
    void reset_v_index_map();
47
    void reset_e_index_map();
48
    void update_v_index_map(Vertex new_vertex);
49
    void update_e_index_map(Edge new_edge);
50

    
51
    NameVertexMap v_id_vertex_map_;
52

    
53
    // VertexIndexMap - since we use listS instead of vecS, this one maps each vertex to an id
54
    VertexIndexStdMap v_index_std_map_;
55
    VertexIndexMap v_index_map_; //
56

    
57
    // EdgeIndexMap - boost will return the component id that each edge in the graph belongs to.
58
    EdgeIndexStdMap e_index_std_map_;
59
    EdgeIndexMap e_index_map_;
60
};
61

    
62
#endif //GRAPH_PARSER_GRAPH_MANAGER_H
63