Skip to content

Commit 6b8257a

Browse files
InterdisciplinaryPhysicsTeampitmonticoneClaudMor
committed
Update docstrings
Co-Authored-By: Pietro Monticone <[email protected]> Co-Authored-By: Claudio Moroni <[email protected]>
1 parent 94b994e commit 6b8257a

File tree

2 files changed

+92
-27
lines changed

2 files changed

+92
-27
lines changed

docs/src/API.md

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# API
22

3-
This page lists all exported methods, organizing them by topic (whether it is a method that acts on vertices, edges, layers, etc) and by audience: due to how it was possible to integrate multilayer graphs within the `Graphs.jl` ecosystem, some methods are intended for developers who wish to use this library just as any other `Graphs.jl` package in their code, while others are meant to be employed by the end-user.
3+
This page provides a list of exported methods organized by topic and audience. Methods that act on vertices, edges, and layers are grouped together. Some methods are intended for developers who want to use the `Graphs.jl` library as part of their code, while others are meant for end-users.
44

55
## End-User
66

@@ -191,15 +191,60 @@ specify_interlayer!(
191191
mg::M,
192192
new_interlayer::In
193193
) where {T,U,G<:AbstractGraph{T},M<:AbstractMultilayerUGraph{T,U},In<:Interlayer{T,U,G}}
194+
195+
get_interlayer(
196+
mg::AbstractMultilayerGraph, layer_1_name::Symbol, layer_2_name::Symbol
197+
)
198+
199+
200+
indegree( mg::AbstractMultilayerGraph, v::MultilayerVertex)
201+
indegree(mg::AbstractMultilayerGraph, vs::AbstractVector{V}=vertices(mg))
202+
203+
outdegree(mg::AbstractMultilayerGraph, mv::MultilayerVertex)
204+
outdegree(mg::AbstractMultilayerGraph, vs::AbstractVector{<:MultilayerVertex}=vertices(mg))
205+
206+
degree(mg::AbstractMultilayerGraph, vs::AbstractVector{<:MultilayerVertex}=vertices(mg))
207+
208+
mean_degree(mg::AbstractMultilayerGraph)
209+
210+
degree_second_moment(mg::AbstractMultilayerGraph)
211+
212+
degree_variance(mg::AbstractMultilayerGraph)
213+
214+
MultilayerGraphs.weighttype(::M) where {T,U,M<:AbstractMultilayerGraph{T,U}}
215+
216+
multilayer_global_clustering_coefficient(
217+
mg::AbstractMultilayerGraph, norm_factor::Union{Float64,Symbol}=:max
218+
)
219+
220+
overlay_clustering_coefficient(
221+
mg::AbstractMultilayerGraph,
222+
norm_factor::Union{Float64,Symbol}=:max
223+
)
224+
225+
eigenvector_centrality(
226+
mg::M; weighted::Bool = true, norm::String="1", tol::Float64=1e-6, maxiter::Int64=2000
227+
) where {T,U,M<:AbstractMultilayerGraph{T,U}}
228+
229+
modularity(
230+
mg::M, c::Matrix{Int64}; null_model::Union{String,Array{U,4}}="degree"
231+
) where {T,U,M<:AbstractMultilayerGraph{T,U}}
232+
233+
234+
von_neumann_entropy(mg::M) where {T,U,M<:AbstractMultilayerUGraph{T,U}}
194235
```
195236

196237
### Representations
197238
```@docs
198239
array(atr::AbstractTensorRepresentation)
199240
WeightTensor{U}
241+
weight_tensor(mg::M) where {T,U, M <: AbstractMultilayerGraph{T,U}}
200242
MetadataTensor{U}
243+
metadata_tensor(mg::M) where {T,U, M <: AbstractMultilayerGraph{T,U}}
201244
array(amr::AbstractMatrixRepresentation)
202245
SupraWeightMatrix{T,U}
246+
supra_weight_matrix(mg::M) where {T,U, M <: AbstractMultilayerGraph{T,U}}
247+
203248
```
204249

205250
### Traits
@@ -285,6 +330,8 @@ edgetype(::M) where {T,U,M<:AbstractMultilayerGraph{T,U}}
285330
has_edge(mg::M, src::T, dst::T) where { T, M <: AbstractMultilayerUGraph{T}}
286331
has_edge(mg::M, src::T, dst::T) where { T, M <: AbstractMultilayerDiGraph{T}}
287332
rem_edge!(mg::M, src::T, dst::T) where {T, M <: AbstractMultilayerGraph{T}
333+
AbstractMultilayerUGraph{T,U}
334+
288335
```
289336

290337
### Representations

src/abstractmultilayergraph.jl

Lines changed: 44 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -415,13 +415,16 @@ end
415415

416416

417417
"""
418-
get_interlayer(mg::M, layer_1::Symbol, layer_2::Symbol) where {M <: AbstractMultilayerGraph}
418+
get_interlayer(
419+
mg::AbstractMultilayerGraph, layer_1_name::Symbol,
420+
layer_2_name::Symbol
421+
)
419422
420423
Return the `Interlayer` between `layer_1` and `layer_2`.
421424
"""
422425
function get_interlayer(
423-
mg::M, layer_1_name::Symbol, layer_2_name::Symbol
424-
) where {M<:AbstractMultilayerGraph}
426+
mg::AbstractMultilayerGraph, layer_1_name::Symbol, layer_2_name::Symbol
427+
)
425428

426429
layer_1_name mg.layers_names || throw(ErrorException("$layer_1_name doesn't belong to the multilayer graph. Available layers are $(mg.layers_names)."))
427430
layer_2_name mg.layers_names || throw(ErrorException("$layer_2_name doesn't belong to the multilayer graph. Available layers are $(mg.layers_names)."))
@@ -479,39 +482,39 @@ end
479482

480483
# Graphs.jl's internals and ecosystem extra overrides
481484
"""
482-
indegree( mg::M, v::V) where {T,M<:AbstractMultilayerGraph{T,<:Real},V<:MultilayerVertex}
485+
indegree( mg::AbstractMultilayerGraph, v::MultilayerVertex)
483486
484487
Get the indegree of vertex `v` in `mg`.
485488
"""
486-
Graphs.indegree( mg::M, v::V) where {T,M<:AbstractMultilayerGraph{T,<:Real},V<:MultilayerVertex} = length(inneighbors(mg, v))
489+
Graphs.indegree( mg::AbstractMultilayerGraph, v::MultilayerVertex) = length(inneighbors(mg, v))
487490

488491
"""
489492
indegree( mg::M, vs::AbstractVector{V}=vertices(mg)) where {T,M<:AbstractMultilayerGraph{T,<:Real},V<:MultilayerVertex}
490493
491494
Get the vector of indegrees of vertices `vs` in `mg`.
492495
"""
493-
Graphs.indegree( mg::M, vs::AbstractVector{V}=vertices(mg)) where {T,M<:AbstractMultilayerGraph{T,<:Real},V<:MultilayerVertex} = [indegree(mg, x) for x in vs]
496+
Graphs.indegree(mg::AbstractMultilayerGraph, vs::AbstractVector{<:MultilayerVertex}=vertices(mg)) = [indegree(mg, x) for x in vs]
494497

495498
"""
496-
outdegree(mg::M, v::V) where {T,M<:AbstractMultilayerGraph{T,<:Real},V<:MultilayerVertex}
499+
outdegree(mg::AbstractMultilayerGraph, mv::MultilayerVertex)
497500
498501
Get the outdegree of vertex `v` in `mg`.
499502
"""
500-
Graphs.outdegree(mg::M, v::V) where {T,M<:AbstractMultilayerGraph{T,<:Real},V<:MultilayerVertex} = length(outneighbors(mg, v))
503+
Graphs.outdegree(mg::AbstractMultilayerGraph, mv::MultilayerVertex) = length(outneighbors(mg, v))
501504

502505
"""
503506
outdegree(mg::M, vs::AbstractVector{V}=vertices(mg)) where {T,M<:AbstractMultilayerGraph{T,<:Real},V<:MultilayerVertex}
504507
505508
Get the vector of outdegrees of vertices `vs` in `mg`.
506509
"""
507-
Graphs.outdegree(mg::M, vs::AbstractVector{V}=vertices(mg)) where {T,M<:AbstractMultilayerGraph{T,<:Real},V<:MultilayerVertex} = [outdegree(mg, x) for x in vs]
510+
Graphs.outdegree(mg::AbstractMultilayerGraph, vs::AbstractVector{<:MultilayerVertex}=vertices(mg)) = [outdegree(mg, x) for x in vs]
508511

509512
"""
510-
degree(mg::M, vs::AbstractVector{V}=vertices(mg)) where {T,M<:AbstractMultilayerGraph{T,<:Real},V<:MultilayerVertex}
513+
degree(mg::AbstractMultilayerGraph, vs::AbstractVector{<:MultilayerVertex}=vertices(mg))
511514
512515
Get the degree of vertices `vs` in `mg`.
513516
"""
514-
Graphs.degree(mg::M, vs::AbstractVector{V}=vertices(mg)) where {T,M<:AbstractMultilayerGraph{T,<:Real},V<:MultilayerVertex} = [degree(mg, x) for x in vs]
517+
Graphs.degree(mg::AbstractMultilayerGraph, vs::AbstractVector{<:MultilayerVertex}=vertices(mg)) = [degree(mg, x) for x in vs]
515518

516519
"""
517520
inneighbors( mg::AbstractMultilayerGraph, mv::MultilayerVertex )
@@ -554,7 +557,7 @@ Get the neighbors of vertex `mv` in `mg`. Reduces to `outneighbors` for both dir
554557
Graphs.neighbors(mg::AbstractMultilayerGraph, mv::MultilayerVertex) = outneighbors(mg, mv)
555558

556559
"""
557-
weighttype(mg::M) where {M <: AbstractMultilayerGraph}
560+
weighttype(::M) where {T,U,M<:AbstractMultilayerGraph{T,U}}
558561
559562
Return the weight type of `mg` (i.e. the eltype of the weight tensor or the supra-adjacency matrix).
560563
"""
@@ -759,34 +762,37 @@ function metadata_tensor(mg::M) where {T,U, M <: AbstractMultilayerGraph{T,U}}
759762
end
760763

761764
"""
762-
mean_degree(mg::M) where { M <: AbstractMultilayerGraph}
765+
mean_degree(mg::AbstractMultilayerGraph)
763766
764767
Return the mean of the degree sequence of `mg`.
765768
"""
766-
mean_degree(mg::M) where {M<:AbstractMultilayerGraph} = mean(degree(mg))
769+
mean_degree(mg::AbstractMultilayerGraph) = mean(degree(mg))
767770

768771
"""
769-
degree_second_moment(mg::M) where { M <: AbstractMultilayerGraph}
772+
degree_second_moment(mg::AbstractMultilayerGraph)
770773
771774
Calculate the second moment of the degree sequence of `mg`.
772775
"""
773-
degree_second_moment(mg::M) where {M<:AbstractMultilayerGraph} = mean(degree(mg) .^ 2)
776+
degree_second_moment(mg::AbstractMultilayerGraph) = mean(degree(mg) .^ 2)
774777

775778
"""
776-
degree_variance(mg::M) where { M <: AbstractMultilayerGraph}
779+
degree_variance(mg::AbstractMultilayerGraph)
777780
778781
Return the variance of the degree sequence of `mg`.
779782
"""
780-
degree_variance(mg::M) where {M<:AbstractMultilayerGraph} = var(degree(mg))
783+
degree_variance(mg::AbstractMultilayerGraph) = var(degree(mg))
781784

782785
"""
783-
multilayer_clustering_coefficient(mg::M, norm_factor::Union{Float64, Symbol} = :max) where {M <: AbstractMultilayerGraph}
786+
multilayer_global_clustering_coefficient(
787+
mg::AbstractMultilayerGraph,
788+
norm_factor::Union{Float64,Symbol}=:max
789+
)
784790
785791
Return the complete multilayer global clustering coefficient, equal to the ratio of realized triplets over all possible triplets, including those whose every or some edges belong to interlayers, normalized by `norm_factor`. If `norm_factor == :max`, then the ratio is normalized by `maximum(mg.array)`. This function does not override Graphs.jl's `global_clustering_coefficient`, since the latter does not consider cliques where two nodes are the same node but in different layers/interlayers. See [De Domenico et al. (2013)](https://doi.org/10.1103/PhysRevX.3.041022).
786792
"""
787793
function multilayer_global_clustering_coefficient(
788-
mg::M, norm_factor::Union{Float64,Symbol}=:max
789-
) where {M<:AbstractMultilayerGraph}
794+
mg::AbstractMultilayerGraph, norm_factor::Union{Float64,Symbol}=:max
795+
)
790796
wgt = weight_tensor(mg).array
791797

792798
_normalization_inverse = 1.0
@@ -848,13 +854,16 @@ function multilayer_weighted_global_clustering_coefficient(
848854
end
849855

850856
"""
851-
overlay_clustering_coefficient(mg::M, norm_factor::Union{Float64, Symbol} = :max) where {M <: AbstractMultilayerGraph}
857+
overlay_clustering_coefficient(
858+
mg::AbstractMultilayerGraph,
859+
norm_factor::Union{Float64,Symbol}=:max
860+
)
852861
853862
Return the overlay clustering coefficient as calculated in [De Domenico et al. (2013)](https://doi.org/10.1103/PhysRevX.3.041022).
854863
"""
855864
function overlay_clustering_coefficient(
856-
mg::M, norm_factor::Union{Float64,Symbol}=:max
857-
) where {M<:AbstractMultilayerGraph}
865+
mg::AbstractMultilayerGraph, norm_factor::Union{Float64,Symbol}=:max
866+
)
858867

859868
wgt = weight_tensor(mg).array
860869

@@ -886,7 +895,12 @@ function overlay_clustering_coefficient(
886895
end
887896

888897
"""
889-
eigenvector_centrality(mg::M; norm::String = "1", tol::Float64 = 1e-6, maxiter::Int64 = 2000) where {T, U, M <: AbstractMultilayerGraph{T, U}}
898+
eigenvector_centrality(
899+
mg::M;
900+
norm::String = "1",
901+
tol::Float64 = 1e-6,
902+
maxiter::Int64 = 2000
903+
) where {T, U, M <: AbstractMultilayerGraph{T, U}}
890904
891905
Calculate the eigenvector centrality of `mg` via an iterative algorithm. The `norm` parameter may be `"1"` or `"n"`, and respectively the eigenvector centrality will be normalized to 1 or further divided by the number of nodes of `mg`. The `tol` parameter terminates the approximation when two consecutive iteration differ by no more than `tol`. The `maxiters` parameter terminates the algorithm when it goes beyond `maxiters` iterations.
892906
@@ -944,7 +958,11 @@ function Graphs.eigenvector_centrality(
944958
end
945959

946960
"""
947-
modularity(mg::M, c::Matrix{Int64}; null_model::Union{String,Array{U,4}} = "degree") where {T, U, M <: AbstractMultilayerGraph{T,U}}
961+
modularity(
962+
mg::M,
963+
c::Matrix{Int64};
964+
null_model::Union{String,Array{U,4}} = "degree"
965+
) where {T, U, M <: AbstractMultilayerGraph{T,U}}
948966
949967
Calculate the modularity of `mg`, as shown in [De Domenico et al. (2013)](https://doi.org/10.1103/PhysRevX.3.041022).
950968
"""

0 commit comments

Comments
 (0)