Revision 162e1bda custompackages/graph-parser/src/graph_manager.cpp

View differences:

custompackages/graph-parser/src/graph_manager.cpp
38 38

  
39 39
    string s1 = vp1.id;
40 40
    string s2 = vp2.id;
41
    Vertex v1;
42
    Vertex v2;
43 41

  
44
    try {
45
        v1 = get_vertex_from_id(s1);
42
    if (s1 != s2) { // do not add self-loop into the graph
43
        Vertex v1;
44
        Vertex v2;
45

  
46
        try {
47
            v1 = get_vertex_from_id(s1);
48
        }
49
        catch (exception& e) {
50
            v1 = boost::add_vertex(vp1, g_);
51
            v_id_vertex_map_[s1] = v1;
52
            update_v_index_pmap(v1);
53
        }
54
        try {
55
            v2 = get_vertex_from_id(s2);
56
        }
57
        catch (exception& e) {
58
            v2 = boost::add_vertex(vp2, g_);
59
            v_id_vertex_map_[s2] = v2;
60
            update_v_index_pmap(v2);
61
        }
62

  
63
        Edge e;
64
        bool inserted;
65
        boost::tie(e, inserted) = boost::add_edge(v1, v2, ep, g_);
66
        update_e_index_pmap(e);
46 67
    }
47
    catch (exception& e) {
48
        v1 = boost::add_vertex(vp1, g_);
49
        v_id_vertex_map_[s1] = v1;
50
        update_v_index_pmap(v1);
51
    }
52
    try {
53
        v2 = get_vertex_from_id(s2);
54
    }
55
    catch (exception& e) {
56
        v2 = boost::add_vertex(vp2, g_);
57
        v_id_vertex_map_[s2] = v2;
58
        update_v_index_pmap(v2);
59
    }
60

  
61
    Edge e;
62
    bool inserted;
63
    boost::tie(e, inserted) = boost::add_edge(v1, v2, ep, g_);
64
    update_e_index_pmap(e);
65 68
}
66 69

  
67 70
void GraphManager::ResetVerticesAndEdgesIndexMap() {

Also available in: Unified diff