Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++ to compute conductance #58

Merged
merged 10 commits into from
Sep 10, 2018
Merged

C++ to compute conductance #58

merged 10 commits into from
Sep 10, 2018

Conversation

MengLiuPurdue
Copy link
Collaborator

No description provided.

@coveralls
Copy link

coveralls commented Sep 5, 2018

Pull Request Test Coverage Report for Build 19

  • 70 of 70 (100.0%) changed or added relevant lines in 6 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+30.1%) to 92.115%

Totals Coverage Status
Change from base Build 9: 30.1%
Covered Lines: 1285
Relevant Lines: 1395

💛 - Coveralls

@@ -403,30 +408,37 @@ def neighbors(self,vertex):
"""
return self.adjacency_matrix[:,vertex].nonzero()[0].tolist()

def compute_conductance(self,R):
def compute_conductance(self,R,cpp=True):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's drop this function. The work is the same as set_scores.

@@ -8,6 +8,7 @@
#include "sparserank.hpp" // include our sorted-list functions
#include "sparsevec.hpp" // include our sparse hashtable functions
#include <tuple>
#include <iostream>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't have iostream here.

@@ -216,6 +218,26 @@ pair<itype, itype> graph<vtype,itype>::get_stats(unordered_map<vtype, vtype>& R_
return set_stats;
}

template<typename vtype, typename itype>
pair<double, double> graph<vtype,itype>::get_stats_weighted(unordered_map<vtype, vtype>& R_map, vtype nR)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason these are using an unordered_map vs. unordered_set ?

#include <stdlib.h>
#include <unordered_map>
#include <queue>
#include <iostream>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should remove iostream

{
graph<uint32_t,uint32_t> g(ai[n],n,ai,aj,NULL,offset,NULL);
unordered_map<uint32_t, uint32_t> R_map;
for (size_t i = 0; i < nR; i ++) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This for loop is duplicated in each of the calls. Can you turn it into a function?

@dgleich
Copy link
Collaborator

dgleich commented Sep 7, 2018

@MengLiuPurdue the right place for the matplotlib.agg is in the test_examples() function in test_notebooks.py

So it shouldn't be in the ipynb file, or in the main code... only in the test_notebooks.py file..

@@ -29,4 +30,76 @@ def _exec_notebook(notebook_filename):
ep.preprocess(nb, {'metadata': {'path': 'notebooks/'}})

def test_examples():
_exec_notebook('notebooks/examples.ipynb')
_exec_notebook('notebooks/examples.ipynb')
"""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add a link to where this code came from!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, working on it. I also in the middle of adding more tests to get the coverage higher than 90% hopefully.

int64_t n, int64_t* ai, int64_t* aj, double* a, double* degrees, int64_t offset,
int64_t* R, int64_t nR, double* voltrue, double* cut)
{
graph<int64_t,int64_t> g(ai[n],n,ai,aj,a,offset,degrees);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure you convert the tabs to spaces.

@MengLiuPurdue
Copy link
Collaborator Author

MengLiuPurdue commented Sep 7, 2018

@dgleich "So it shouldn't be in the ipynb file, or in the main code... only in the test_notebooks.py file.." I tried, but that didn't seem to work.

UPDATE: I found a way to do that by deleting "init.py" inside "tests/" and add those two lines in "conftest.py". Because otherwise, pytest will always import localgraphclustering first. (https://docs.pytest.org/en/latest/pythonpath.html)

@@ -24,7 +24,13 @@ def load_library():
lib=ctypes.cdll.LoadLibrary(find_path())
return lib

def is_loaded(lib):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove this ,it wlll never work on windows.

@dgleich dgleich merged commit eee8e7d into kfoynt:master Sep 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants