-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding Louvain clustering (weighted) on Mac and Windows
- Loading branch information
Showing
14 changed files
with
139 additions
and
190 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ language: julia | |
|
||
os: | ||
- osx | ||
- linux | ||
|
||
julia: | ||
- 1.4 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
name = "CGE" | ||
uuid = "f7ff1d1e-e254-4b26-babe-fc3421add060" | ||
authors = ["KrainskiL <[email protected]>"] | ||
version = "1.0.1" | ||
version = "1.1.0" | ||
|
||
[deps] | ||
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
####################### | ||
# Community detection # | ||
####################### | ||
|
||
""" | ||
louvain(edges::String) | ||
Calculate communities in graph using [Louvain algoritm](https://sites.google.com/site/findcommunities/) | ||
**Arguments** | ||
* `edges::String` name of file with edges definition | ||
""" | ||
function louvain(edges::String) | ||
BASEPATH = dirname(dirname(pathof(CGE))) | ||
TMP = Sys.iswindows() ? ENV["TEMP"] : "/tmp" | ||
if Sys.iswindows() | ||
TMP = ENV["TEMP"] | ||
run(`$BASEPATH/bin/win/convert.exe -i $edges -o $TMP/louvain.bin`) | ||
run(pipeline(`$BASEPATH/bin/win/louvain.exe $TMP/louvain.bin -l -1 -q id_qual`, stdout="$TMP/louvain.txt")) | ||
run(pipeline(`$BASEPATH/bin/win/hierarchy.exe $TMP/louvain.txt -l 1`,"$edges.ecg")) | ||
else | ||
chmod(joinpath(BASEPATH,"bin/unix/"),0o744,recursive=true) | ||
run(`$BASEPATH/bin/unix/convert -i $edges -o $TMP/louvain.bin`) | ||
run(pipeline(`$BASEPATH/bin/unix/louvain $TMP/louvain.bin -l -1 -q id_qual`, stdout="$TMP/louvain.txt")) | ||
run(pipeline(`$BASEPATH/bin/unix/hierarchy $TMP/louvain.txt -l 1`,"$edges.ecg")) | ||
end | ||
end | ||
|
||
""" | ||
louvain(filename::String, edges::Array{Int,2}, weights::Array{Float64,1})) | ||
Calculate communities in weighted graph using [Louvain algoritm](https://sites.google.com/site/findcommunities/) | ||
**Arguments** | ||
* `filename::String` name of file with edges definition | ||
* `edges::Array{Int,2}` list of edges | ||
* `weights::Array{Float64,1}` array of egdges' weights | ||
""" | ||
function louvain(filename::String, edges::Array{Int,2}, weights::Array{Float64,1}) | ||
BASEPATH = dirname(dirname(pathof(CGE))) | ||
TMP = Sys.iswindows() ? ENV["TEMP"] : "/tmp" | ||
tmp_edges = joinpath(TMP,filename) | ||
open(tmp_edges, "w") do f | ||
for i in edges println(f, i) end | ||
end | ||
tmp_weights = joinpath(TMP,filename*".weights") | ||
open(tmp_weights, "w") do f | ||
for i in weights println(f, i) end | ||
end | ||
if Sys.iswindows() | ||
run(`$BASEPATH/bin/win/convert.exe -i $tmp_edges -o $TMP/louvain.bin -w $tmp_weights`) | ||
run(pipeline(`$BASEPATH/bin/win/louvain.exe $TMP/louvain.bin -w $tmp_weights -l -1 -q id_qual`, stdout="$TMP/louvain.txt")) | ||
run(pipeline(`$BASEPATH/bin/win/hierarchy.exe $TMP/louvain.txt -l 1`,"$filename.ecg")) | ||
else | ||
chmod(joinpath(BASEPATH,"bin/unix/"),0o744,recursive=true) | ||
run(`$BASEPATH/bin/unix/convert -i $tmp_edges -o $TMP/louvain.bin -w $tmp_weights`) | ||
run(pipeline(`$BASEPATH/bin/unix/louvain $TMP/louvain.bin -w $tmp_weights -l -1 -q id_qual`, stdout="$TMP/louvain.txt")) | ||
run(pipeline(`$BASEPATH/bin/unix/hierarchy $TMP/louvain.txt -l 1`,"$filename.ecg")) | ||
end | ||
end |
Oops, something went wrong.