Skip to content

Commit

Permalink
Add phase 4 and operator<< implementation
Browse files Browse the repository at this point in the history
- Fix previous existing phases needed for phase 4
- Add helper function for saving output

Co-authored-by: claudiolor <[email protected]>
  • Loading branch information
morpheusthewhite and claudiolor committed Jun 23, 2020
1 parent 6bdd40d commit a598490
Show file tree
Hide file tree
Showing 3 changed files with 201 additions and 43 deletions.
25 changes: 19 additions & 6 deletions include/GraphParallelDFS.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,19 @@ class GraphParallelDFS {

friend ostream& operator<<(ostream& os, GraphParallelDFS& graphParallelDfs);

// create output file
void saveTo(const string& filename);

// getters here
int getNNodes() const;

const vector<int> &getAp() const;
const vector<int> &getAp_dag() const;

const vector<int> &getAi_dag() const;

const vector<int> &getAi() const;
const vector<int> &getAp_dt() const;

const vector<int> &getRoots() const;
const vector<int> &getAi_dt() const;

const vector<int> &getEV() const;

Expand All @@ -58,8 +63,11 @@ class GraphParallelDFS {
void computeRanks();

int n_nodes;
vector<int> Ap;
vector<int> Ai;
vector<int> Ap_dag;
vector<int> Ai_dag;

vector<int> Ap_dt;
vector<int> Ai_dt;

// precomputed leaves and roots
vector<int> leaves;
Expand All @@ -76,8 +84,13 @@ class GraphParallelDFS {

vector<int> gamma;
vector<int> gamma_tilde;
vector<int> parents;
vector<int> post_order;

// contains the parent of each node in the dt
vector<int> parents;

// contains all the parents of each node in the dag
vector<vector<int>> parents_dag;
};


Expand Down
22 changes: 22 additions & 0 deletions include/OutputFileException.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// Created by claud on 23/06/2020.
//

#ifndef PARALLEL_DFS_DAG_OUTPUTFILEEXCEPTION_H
#define PARALLEL_DFS_DAG_OUTPUTFILEEXCEPTION_H

using namespace std;

class OutputFileException : exception {
public:
OutputFileException() : message("Unable to open the output file") {}
explicit OutputFileException(const char * message) : message(message) {}

const char * what() {
return message;
}
private:
const char * message;
};

#endif //PARALLEL_DFS_DAG_OUTPUTFILEEXCEPTION_H
Loading

0 comments on commit a598490

Please sign in to comment.