Skip to content

Commit 4821df3

Browse files
authored
Merge pull request #6 from storopoli/master
Move from LightGraphs to Graphs
2 parents 6a5f10f + 6c99963 commit 4821df3

File tree

6 files changed

+41
-15
lines changed

6 files changed

+41
-15
lines changed

.gitignore

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
.DS_Store
12
*.jl.cov
2-
*.jl.*.cov
33
*.jl.mem
4+
.vscode
5+
docs/build/
6+
docs/site/
7+
benchmark/.results/*
8+
benchmark/.tune.jld
9+
*.cov
10+
Manifest.toml

Project.toml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name = "CommunityDetection"
2+
uuid = "d427f087-d71a-5a1b-ace0-b93392eea9ff"
3+
authors = ["JuliaGraphs"]
4+
version = "0.2.0"
5+
6+
[deps]
7+
ArnoldiMethod = "ec485272-7323-5ecc-a04f-4719b315124d"
8+
Clustering = "aaaa29a8-35af-508c-8bc3-b662a17a0fe5"
9+
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
10+
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
11+
12+
[compat]
13+
ArnoldiMethod = "0.2"
14+
Clustering = "0.14"
15+
Graphs = "1.4"
16+
julia = "1"
17+
18+
[extras]
19+
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
20+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
21+
22+
[targets]
23+
test = ["SparseArrays", "Test"]

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55

66
### CommunityDetection.jl
77

8-
Implements community detection for [LightGraphs.jl](https://github.com/JuliaGraphs/LightGraphs.jl). Both Nonbacktracking and Bethe Hessian detection are supported.
8+
Implements community detection for [Graphs.jl](https://github.com/JuliaGraphs/Graphs.jl). Both Nonbacktracking and Bethe Hessian detection are supported.

REQUIRE

Lines changed: 0 additions & 4 deletions
This file was deleted.

src/CommunityDetection.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module CommunityDetection
2-
using LightGraphs
2+
using Graphs
33
using ArnoldiMethod: LR, SR
44
using LinearAlgebra: I, Diagonal
55
using Clustering: kmeans
@@ -57,7 +57,7 @@ See `Nonbacktracking` for details.
5757
"""
5858
function nonbacktrack_embedding(g::AbstractGraph, k::Int)
5959
B = Nonbacktracking(g)
60-
λ, eigv = LightGraphs.LinAlg.eigs(B, nev=k+1, which=LR())
60+
λ, eigv = Graphs.LinAlg.eigs(B, nev=k+1, which=LR())
6161
ϕ = zeros(ComplexF32, nv(g), k-1)
6262
# TODO decide what to do with the stationary distribution ϕ[:,1]
6363
# this code just throws it away in favor of eigv[:,2:k+1].
@@ -93,7 +93,7 @@ function community_detection_bethe(g::AbstractGraph, k::Int=-1; kmax::Int=15)
9393
Hr = Matrix((r^2-1)*I, nv(g), nv(g)) - r*A + D;
9494
#Hmr = Matrix((r^2-1)*I, nv(g), nv(g)) + r*A + D;
9595
k >= 1 && (kmax = k)
96-
λ, eigv = LightGraphs.LinAlg.eigs(Hr, which=SR(), nev=min(kmax, nv(g)))
96+
λ, eigv = Graphs.LinAlg.eigs(Hr, which=SR(), nev=min(kmax, nv(g)))
9797

9898
# TODO eps() is chosen quite arbitrarily here, because some of eigenvalues
9999
# don't convert exactly to zero as they should. Some analysis could show

test/runtests.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using CommunityDetection
2-
using LightGraphs
2+
using Graphs
33
using LinearAlgebra: I, norm
44
using ArnoldiMethod: LR
55
using SparseArrays: sparse
@@ -15,7 +15,7 @@ return : a matrix ϕ where ϕ[:,i] are the coordinates for vertex i.
1515
"""
1616
function nonbacktrack_embedding_dense(g::AbstractGraph, k::Int)
1717
B, edgeid = non_backtracking_matrix(g)
18-
λ, eigv = LightGraphs.LinAlg.eigs(B, nev=k+1, which=LR())
18+
λ, eigv = Graphs.LinAlg.eigs(B, nev=k+1, which=LR())
1919
ϕ = zeros(ComplexF32, k-1, nv(g))
2020
# TODO decide what to do with the stationary distribution ϕ[:,1]
2121
# this code just throws it away in favor of eigv[:,2:k+1].
@@ -36,7 +36,7 @@ end
3636
@testset "CommunityDetection" begin
3737

3838
n = 10; k = 5
39-
pg = PathGraph(n)
39+
pg = path_graph(n)
4040
ϕ1 = CommunityDetection.nonbacktrack_embedding(pg, k)'
4141

4242
nbt = Nonbacktracking(pg)
@@ -61,7 +61,7 @@ z = B * x
6161
#check that this recovers communities in the path of cliques
6262
@testset "community_detection_nback(z, k)" begin
6363
n=10
64-
g10 = CompleteGraph(n)
64+
g10 = complete_graph(n)
6565
z = copy(g10)
6666
for k=2:5
6767
z = blockdiag(z, g10)
@@ -80,7 +80,7 @@ end
8080

8181
@testset "community_detection_bethe(z, k)" begin
8282
n=10
83-
g10 = CompleteGraph(n)
83+
g10 = complete_graph(n)
8484
z = copy(g10)
8585
for k=2:5
8686
z = blockdiag(z, g10)
@@ -101,7 +101,7 @@ end
101101

102102
@testset "community_detection_bethe(z)" begin
103103
n=10
104-
g10 = CompleteGraph(n)
104+
g10 = complete_graph(n)
105105
z = copy(g10)
106106
for k=2:5
107107
z = blockdiag(z, g10)

0 commit comments

Comments
 (0)