File tree Expand file tree Collapse file tree 4 files changed +43
-2
lines changed Expand file tree Collapse file tree 4 files changed +43
-2
lines changed Original file line number Diff line number Diff line change 11# RecurrenceAnalysis.jl News
22
3+ ## v1.5.2
4+ - New, faster formula for ` rna[:averagepath] ` allowing disconnected graphs.
5+
36## v1.5.1
47- Minor documentation fixes.
58
Original file line number Diff line number Diff line change 11name = " RecurrenceAnalysis"
22uuid = " 639c3291-70d9-5ea2-8c5b-839eba1ee399"
33repo = " https://github.com/JuliaDynamics/RecurrenceAnalysis.jl.git"
4- version = " 1.5.1 "
4+ version = " 1.5.2 "
55
66[deps ]
77DelayEmbeddings = " 5732040d-69e3-5649-938a-b6b4f237613f"
Original file line number Diff line number Diff line change @@ -43,7 +43,22 @@ function rna(args...; kwargs...)
4343 return Dict {Symbol, Float64} (
4444 :density => density (graph),
4545 :transitivity => global_clustering_coefficient (graph),
46- :averagepath => mean ( 1 ./ closeness_centrality ( graph) ),
46+ :averagepath => averagepath ( graph),
4747 :diameter => diameter (graph)
4848 )
4949end
50+
51+ """
52+ averagepath(graph)
53+
54+ Calculates average minimum path length for a SimpleGraph.
55+ Uses Donner, 2010, Eq. 26 on pg. 18.
56+ """
57+ function averagepath (graph:: SimpleGraph )
58+ num_verts = nv (graph)
59+
60+ dist_mat = floyd_warshall_shortest_paths (graph). dists
61+ @. dist_mat[dist_mat == typemax (dist_mat)] = 0.
62+
63+ return sum (dist_mat) / (num_verts * (num_verts - 1 ))
64+ end
Original file line number Diff line number Diff line change 184184 @test rna_dict[:transitivity ] ≈ sum (triangles) / sum (triples)
185185 @test rna_dict[:averagepath ] ≈ sum (dismat9) / (9 * 8 )
186186 @test rna_dict[:diameter ] == maximum (dismat9)
187+ adjmat11 = [0 0 0 1 0 0 0 1 0 0
188+ 0 0 0 0 1 0 0 0 1 0
189+ 0 0 0 0 0 1 0 0 0 0
190+ 1 0 0 0 0 0 1 0 0 0
191+ 0 1 0 0 0 0 0 1 0 0
192+ 0 0 1 0 0 0 0 0 1 0
193+ 0 0 0 1 0 0 0 0 0 0
194+ 1 0 0 0 1 0 0 0 0 0
195+ 0 1 0 0 0 1 0 0 0 0
196+ 0 0 0 0 0 0 0 0 0 0 ]
197+ dismat11 = [0 3 6 1 2 5 2 1 4 Inf
198+ 3 0 3 4 1 2 5 2 1 Inf
199+ 6 3 0 7 4 1 8 5 2 Inf
200+ 1 4 7 0 3 6 1 2 5 Inf
201+ 2 1 4 3 0 3 4 1 2 Inf
202+ 5 2 1 6 3 0 7 4 1 Inf
203+ 2 5 8 1 4 7 0 3 6 Inf
204+ 1 2 5 2 1 4 3 0 3 Inf
205+ 4 1 2 5 2 1 6 3 0 Inf
206+ Inf Inf Inf Inf Inf Inf Inf Inf Inf 0 ]
207+ rna_dict = rna (RecurrenceMatrix (adjmat11))
208+ @test ! isinf (rna_dict[:averagepath ])
209+ @test rna_dict[:averagepath ] ≈ sum (dismat11[1 : 9 ,1 : 9 ]) / (9 * 10 )
187210end
You can’t perform that action at this time.
0 commit comments