Skip to content

Commit

Permalink
addGraphAlg is not internal to accessibility
Browse files Browse the repository at this point in the history
  • Loading branch information
fscottfoti committed May 26, 2017
1 parent 5f2abe7 commit 0690f6d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
12 changes: 10 additions & 2 deletions src/accessibility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,16 @@ bool distance_node_pair_comparator(const distance_node_pair& l,
const distance_node_pair& r)
{ return l.first < r.first; }

Accessibility::Accessibility(int numnodes) {
this->numnodes = numnodes;
Accessibility::Accessibility(
vector<long> nodeids, vector< vector<double> > nodexy,
vector< vector<long> > edges, vector< vector<double> > edgeweights,
bool twoway) {
for (int i = 0 ; i < edgeweights.size() ; i++) {
this->addGraphalg(new Graphalg(
nodeids, nodexy, edges, edgeweights[i], twoway));
}

this->numnodes = nodeids.size();
this->dmsradius = -1;
}

Expand Down
9 changes: 6 additions & 3 deletions src/accessibility.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ using std::vector;

class Accessibility {
public:
explicit Accessibility(int numnodes = 0);

void addGraphalg(MTC::accessibility::Graphalg *g);
Accessibility(
vector<long> nodeids, vector< vector<double> > nodexy,
vector< vector<long> > edges, vector< vector<double> > edgeweights,
bool twoway);

// set how many POI categories there will be
void initializePOIs(
Expand Down Expand Up @@ -97,6 +98,8 @@ class Accessibility {
DECAY_MAXVAL
};

void addGraphalg(MTC::accessibility::Graphalg *g);

vector<double>
findNearestPOIs(
int srcnode,
Expand Down
17 changes: 4 additions & 13 deletions src/cyaccess.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,12 @@ cimport numpy as np
# http://cython.readthedocs.io/en/latest/src/userguide/wrapping_CPlusPlus.html
# http://www.birving.com/blog/2014/05/13/passing-numpy-arrays-between-python-and/

cdef extern from "graphalg.h" namespace "MTC::accessibility":
cdef cppclass Graphalg:
Graphalg(vector[long], vector[vector[double]], vector[vector[long]],
vector[double], bool) except +


cdef extern from "accessibility.h" namespace "MTC::accessibility":
cdef cppclass Accessibility:
Accessibility(int) except +
int numnodes
void addGraphalg(Graphalg*)
Accessibility(
vector[long], vector[vector[double]], vector[vector[long]],
vector[vector[double]], bool) except +
void initializePOIs(int, double, int)
void initializeCategory(int, vector[long])
vector[vector[double]] findAllNearestPOIs(
Expand Down Expand Up @@ -68,11 +63,7 @@ cdef class cyaccess:
twoway: whether the edges should all be two-way or whether they
are directed from the first to the second node
"""
self.access = new Accessibility(len(node_ids))

for i in range(edge_weights.shape[0]):
self.access.addGraphalg(new Graphalg(
node_ids, node_xys, edges, edge_weights[i], twoway))
self.access = new Accessibility(node_ids, node_xys, edges, edge_weights, twoway)

def __dealloc__(self):
del self.access
Expand Down

0 comments on commit 0690f6d

Please sign in to comment.