Skip to content

Commit d3dd88d

Browse files
committed
updated output file format
1 parent e5f9388 commit d3dd88d

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

docker-wrappers/RWR/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
## Notes
33
The random walk with restarts algorithm requires a directed input network. However, the algorithm in its current form will accept an undirected input network and interpret it as a directed network. The resulting output from an undirected network does not accuratly represent directionality.
44

5+
## Building docker file
6+
to build a new docker image for rwr navigate to the /docker-wrappers/rwr directory and enter:
7+
```
8+
docker build -t ade0brien/rwr -f Dockerfile .
9+
```
510

611
## Testing
712
Test code is located in `test/RWR`.

docker-wrappers/RWR/RWR.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,14 @@ def RWR(network_file: Path, nodes_file: Path, alpha: float, output_file: Path):
5252
# Run pagerank algorithm on directed graph
5353
scores = nx.pagerank(graph,personalization={n:1 for n in nodelist},alpha=alpha)
5454

55+
5556
with output_file.open('w') as output_f:
5657
output_f.write("Node\tScore\n")
57-
for node in list(scores.keys()).sort(desc=True):
58+
node_scores = list(scores.items())
59+
node_scores.sort(reverse=True,key=lambda kv: (kv[1], kv[0]))
60+
for node in node_scores:
5861
#todo: filter scores based on threshold value
59-
output_f.write(f"{node}\t{scores.get(node)}\n")
62+
output_f.write(f"{node[0]}\t{node[1]}\n")
6063
return
6164

6265

0 commit comments

Comments
 (0)