Skip to content

Commit

Permalink
updated spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
vboussange authored and etiennedeg committed Oct 29, 2021
1 parent 9984e54 commit 268c3a6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/community/rich_club.jl
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
"""
rich_club(g,k)
rich_club(g, k)
Return the non-normalised [rich-club coefficient](https://en.wikipedia.org/wiki/Rich-club_coefficient) of graph `g`,
with degree cut-off `k`.
```jldoctest
julia> using LightGraphs
julia> g = star_graph(5)
julia> rich_club(g,1)
julia> rich_club(g, 1)
0.4
```
"""
function rich_club(g::AbstractGraph{T},k::Int) where T
function rich_club(g::AbstractGraph{T}, k::Int) where T
E = zero(T)
for e in edges(g)
if (outdegree(g,src(e)) >= k) && (indegree(g,dst(e)) >= k )
if (outdegree(g, src(e)) >= k) && (indegree(g, dst(e)) >= k )
E +=1
end
end
Expand Down
12 changes: 6 additions & 6 deletions test/community/rich_club.jl
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@

@testset "Rich club coefficient" begin
@testset "Small graphs" for _n in 5:10
@test @inferred rich_club(star_graph(_n),1) 2 / _n
@test @inferred rich_club(DiGraph(star_graph(_n)),1) 2 / _n
@test @inferred rich_club(star_graph(_n), 1) 2 / _n
@test @inferred rich_club(DiGraph(star_graph(_n)), 1) 2 / _n
end
@testset "Directed ($seed)" for seed in [1, 2, 3], (n, ne) in [(14, 18), (10, 22), (7, 16)]
g = erdos_renyi(n, ne; is_directed=true, seed=seed)
_r = rich_club(g,1)
@test @inferred rich_club(g,1) > 0.
_r = rich_club(g, 1)
@test @inferred rich_club(g, 1) > 0.
end
@testset "Undirected ($seed)" for seed in [1, 2, 3], (n, ne) in [(14, 18), (10, 22), (7, 16)]
g = erdos_renyi(n, ne; is_directed=false, seed=seed)
_r = rich_club(g,1)
@test @inferred rich_club(g,1) > 0.
_r = rich_club(g, 1)
@test @inferred rich_club(g, 1) > 0.
end
end

0 comments on commit 268c3a6

Please sign in to comment.