Skip to content

Commit

Permalink
Add further check on file format
Browse files Browse the repository at this point in the history
Co-authored-by: claudiolor <[email protected]>
  • Loading branch information
morpheusthewhite and claudiolor committed Jul 2, 2020
1 parent 0c887d8 commit 2d5b8e0
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/GraphParallelDFS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ GraphParallelDFS::GraphParallelDFS(const string &filename) : n_nodes(0) {
//check the validity of the number of nodes
if(this->n_nodes > 0){
this->incoming_edges.resize(n_nodes);
this->Ap_dag.resize(n_nodes);
}else{
throw InvalidGraphInputFile("Number of node in the graph not valid");
}
Expand All @@ -44,11 +45,15 @@ GraphParallelDFS::GraphParallelDFS(const string &filename) : n_nodes(0) {
char c_buffer;
istringstream stream(buffer);

// save node index in Ap
this->Ap_dag.push_back(this->Ai_dag.size());

// read the first node
stream >> node;

if(node >= n_nodes)
throw InvalidGraphInputFile("Number of node in the graph not valid");

// save node index in Ap
this->Ap_dag[node] = this->Ai_dag.size();

this->Ai_dag.push_back(node);

while(stream >> c_buffer && c_buffer != '#'){
Expand Down

0 comments on commit 2d5b8e0

Please sign in to comment.