Skip to content

Commit

Permalink
add edge_id attr to DGraphEdge for #90
Browse files Browse the repository at this point in the history
  • Loading branch information
mpadge committed Oct 16, 2019
1 parent 880cd4c commit 710f15c
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/centrality.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void inst_graph (std::shared_ptr<DGraph> g, unsigned int nedges,
{
unsigned int fromi = vert_map.at(from [i]);
unsigned int toi = vert_map.at(to [i]);
g->addNewEdge (fromi, toi, dist [i], wt [i]);
g->addNewEdge (fromi, toi, dist [i], wt [i], i);
}
}
// # nocov end
Expand Down
3 changes: 2 additions & 1 deletion src/dgraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,12 @@ void DGraph::initVertices()
* with a corresponding distance of dist.
*/
void DGraph::addNewEdge(unsigned int source, unsigned int target,
double dist, double wt)
double dist, double wt, unsigned int edge_id)
{
DGraphEdge *newEdge = new DGraphEdge;
newEdge->source = source;
newEdge->target = target;
newEdge->edge_id = edge_id;
newEdge->dist = dist;
newEdge->wt = wt;
newEdge->nextOut = nullptr;
Expand Down
4 changes: 2 additions & 2 deletions src/dgraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*/
class DGraphEdge {
public:
unsigned int source, target;
unsigned int source, target, edge_id; // edge_id only used in centrality
double dist, wt;
DGraphEdge *nextOut, *nextIn;
};
Expand Down Expand Up @@ -69,7 +69,7 @@ class DGraph {

void clear();
void addNewEdge(unsigned int srcVertexNo, unsigned int destVertexNo,
double dist, double wt);
double dist, double wt, unsigned int edge_id);
bool edgeExists(unsigned int v, unsigned int w) const;
bool reachable(unsigned int s) const;
void print() const;
Expand Down
2 changes: 1 addition & 1 deletion src/flows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void inst_graph (std::shared_ptr<DGraph> g, unsigned int nedges,
{
unsigned int fromi = vert_map.at(from [i]);
unsigned int toi = vert_map.at(to [i]);
g->addNewEdge (fromi, toi, dist [i], wt [i]);
g->addNewEdge (fromi, toi, dist [i], wt [i], i);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/run_sp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void inst_graph (std::shared_ptr<DGraph> g, unsigned int nedges,
{
unsigned int fromi = vert_map.at(from [i]);
unsigned int toi = vert_map.at(to [i]);
g->addNewEdge (fromi, toi, dist [i], wt [i]);
g->addNewEdge (fromi, toi, dist [i], wt [i], i);
}
}
// # nocov end
Expand Down

0 comments on commit 710f15c

Please sign in to comment.