Revision cb770240 custompackages/graph-parser/src/parser.cpp

View differences:

custompackages/graph-parser/src/parser.cpp
108 108

  
109 109
        addLinkToGraph(source, target, cost, g, routers);
110 110
    }
111
}
112

  
113
void readEdgeFileGraphManager(string filePath, GraphManager &gm) {
114
    // NameVertexMap is to keep track of which router has already been added
115
    ifstream inFile(filePath.c_str());
116

  
117
    vector<string> strs;
118
    for (string line; getline(inFile, line); /**/) {
119
        boost::split(strs, line, boost::is_any_of(" "));
120

  
121
        // Cast vector<string> to array<string, 3>
122
        // TODO: this is really crude way to do it.
123
        // TODO: how to copy some element of vector to array
124
        if (strs.size() == 3) {
125
            string source = strs[0];
126
            string target = strs[1];
127

  
128
            GraphManager::VertexProperties vp1 = GraphManager::VertexProperties(source, source);
129
            GraphManager::VertexProperties vp2 = GraphManager::VertexProperties(target, target);
130

  
131
            // TODO: use atof as a way around the error: ‘stof’ was not declared in this scope
132
            // double cost = stof(strs[2]);
133
            double cost = atof(strs[2].c_str());
134

  
135
            GraphManager::EdgeProperties ep = GraphManager::EdgeProperties(cost);
136

  
137
            gm.AddEdge(vp1, vp2, ep);
138

  
139
        }
140
    }
141
    inFile.close();
111 142
}

Also available in: Unified diff