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

minor bugfixes & optimizations #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ sudo apt-get install libgflags-dev
sudo apt-get install liblog4cxx-dev
sudo apt-get install libomp-dev
sudo apt-get install libeigen3-dev
https://github.com/xptree/NetSMF.git
git clone https://github.com/xptree/NetSMF.git
cd NetSMF
mkdir build
./configure
Expand Down Expand Up @@ -72,7 +72,7 @@ For unweighted networks, see `example/blog.sh` for an example.

`blog.sh` takes three arguments, the first one indicates the input edgelist file, the second one indicates the output file, the third one indicating the origin `.mat` file containing network and labels.

For exmaple, runing `./blog.sh blogcatalog.edgelist blogcatalog.netsmf blogcatalog.mat` will
For exmaple, running `./blog.sh blogcatalog.edgelist blogcatalog.netsmf blogcatalog.mat` will

* check if `blogcatalog.edgelist` is a valid file. If not, it calls `mat2edge.py` to translate mat file `blogcatalog.mat` to edgelist `blogcatalog.edgelist`.
* call NetSMF algorithm, and store the 128-dim embedding at `blogcatalog.netsmf_128.npy`.
Expand Down
12 changes: 5 additions & 7 deletions example/mat2edge.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,17 @@ def load_adjacency_matrix(file, variable_name="network"):
return data[variable_name]

def mat2edge(file, output):
print("mat2edgelist from %s to %s" % (file, output))
print(f"mat2edgelist from {file} to {output}")
A = load_adjacency_matrix(file)
A.eliminate_zeros()
min_v, max_v = min(A.data) , max(A.data)
print("minimum non-zero value=%.2f maximum non-zero value=%.2f" \
% (min_v, max_v))
print(f"minimum non-zero value={min_v:.2f} maximum non-zero value={max_v:.2f}")
unweighted = math.isclose(min_v, 1.0) and math.isclose(max_v, 1.0)
print("unweighted graph" if unweighted else "weighted graph")
A = A.todok()
A = A.tocoo()
with open(output, "w") as f:
for (x, y), v in A.items():
assert(math.isclose(A[y, x], v))
print("%d\t%d" % (x, y) if unweighted else "%d\t%d\t%f" % (x, y, v),end="\n", file=f)
for x, y, v in zip(A.row, A.col, A.data):
print(f"{x}\t{y}" if unweighted else f"{x}\t{y}\t{v}", file=f)

if __name__ == "__main__":
#mat2edge("youtube.mat", "youtube.edge")
Expand Down
2 changes: 1 addition & 1 deletion src/redsvd/redsvd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class RedSVD {

// Compute Sample Matrix of B
Eigen::MatrixXf Z = B * P;
LOG4CXX_INFO(logger, "compute sample matrix of Z = B * P done.")
LOG4CXX_INFO(logger, "compute sample matrix of Z = B * P done.");

// Orthonormalize Z
Util::processGramSchmidt(Z);
Expand Down