Skip to content

Commit a0e197f

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

File tree

4 files changed

+91
-27
lines changed

4 files changed

+91
-27
lines changed

docs/src/API.md

Lines changed: 54 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,10 @@ get_symmetric_interlayer(
141141

142142

143143
```@docs
144-
nodes(mg::MultilayerGraph)
144+
nodes(mg::AbstractMultilayerGraph)
145+
nn(mg::AbstractMultilayerGraph)
146+
add_node!(mg::AbstractMultilayerGraph, n::Node)
147+
rem_node!(mg::AbstractMultilayerGraph, n::Node)
145148
has_vertex(mg::AbstractMultilayerGraph, mv::MultilayerVertex)
146149
nv(mg::M) where {M <: AbstractMultilayerGraph }
147150
mv_vertices(mg::AbstractMultilayerGraph)
@@ -170,8 +173,51 @@ is_directed(m::M) where { M <: Type{ <: AbstractMultilayerDiGraph}}
170173
has_node(mg::AbstractMultilayerGraph, n::Node)
171174
rem_vertex!(mg::AbstractMultilayerUGraph, V::MultilayerVertex)
172175
rem_vertex!(mg::AbstractMultilayerDiGraph, V::MultilayerVertex)
176+
set_metadata!(mg::AbstractMultilayerGraph, mv::MultilayerVertex, metadata::Union{Tuple, NamedTuple})
177+
set_metadata!(mg::AbstractMultilayerDiGraph, src::MultilayerVertex, dst::MultilayerVertex, metadata::Union{Tuple, NamedTuple})
178+
set_metadata!(mg::AbstractMultilayerUGraph, src::MultilayerVertex, dst::MultilayerVertex, metadata::Union{Tuple, NamedTuple})
179+
nl(mg::AbstractMultilayerGraph)
180+
nIn(mg::AbstractMultilayerGraph)
181+
has_layer(mg::AbstractMultilayerGraph, layer_name::Symbol)
182+
183+
add_layer!(mg::M, new_layer::L; default_interlayers_null_graph::H = SimpleGraph{T}(), default_interlayers_structure::String ="multiplex"
184+
) where {T,U,G<:AbstractGraph{T},M<:AbstractMultilayerUGraph{T,U},L<:Layer{T,U,G}, H <: AbstractGraph{T}}
185+
186+
add_layer!(
187+
mg::M, new_layer::L; default_interlayers_null_graph::H = SimpleGraph{T}(), default_interlayers_structure::String ="multiplex"
188+
) where {T,U,G<:AbstractGraph{T},M<:AbstractMultilayerDiGraph{T,U},L<:Layer{T,U,G}, H <: AbstractGraph{T}}
189+
190+
specify_interlayer!(
191+
mg::M,
192+
new_interlayer::In
193+
) where {T,U,G<:AbstractGraph{T},M<:AbstractMultilayerDiGraph{T,U},In<:Interlayer{T,U,G}}
194+
195+
specify_interlayer!(
196+
mg::M,
197+
new_interlayer::In
198+
) where {T,U,G<:AbstractGraph{T},M<:AbstractMultilayerUGraph{T,U},In<:Interlayer{T,U,G}}
173199
```
174200

201+
### Representations
202+
```@docs
203+
array(atr::AbstractTensorRepresentation)
204+
WeightTensor{U}
205+
MetadataTensor{U}
206+
array(amr::AbstractMatrixRepresentation)
207+
SupraWeightMatrix{T,U}
208+
```
209+
210+
### Traits
211+
```@docs
212+
is_weighted(g::G) where { G <: AbstractGraph}
213+
is_weighted(g::G) where {G<:Type{<:AbstractGraph}}
214+
215+
is_meta(g::G) where {G <: AbstractGraph}
216+
is_meta(g::G) where {G<:Type{<:AbstractGraph}}
217+
```
218+
219+
220+
175221
----------------------------------------------------
176222
####################################################
177223
----------------------------------------------------
@@ -226,13 +272,11 @@ rem_vertex!(layer::L, v::T) where {T, L <: Layer{T}}
226272
AbstractInterlayer
227273
```
228274

229-
### Traits
230-
```@docs
231-
```
232275

233276
### Multilayer-specific methods
234277

235278
```@docs
279+
AbstractMultilayerGraph{T <: Integer, U <: Real}
236280
has_vertex(mg::M, v::T) where {T, M <: AbstractMultilayerGraph{T}}
237281
vertices(mg::AbstractMultilayerGraph)
238282
inneighbors(mg::AbstractMultilayerUGraph, v::T) where {T <: Integer, M <: AbstractMultilayerUGraph{T}}
@@ -251,11 +295,14 @@ rem_edge!(mg::M, src::T, dst::T) where {T, M <: AbstractMultilayerGraph{T}
251295
### Representations
252296
```@docs
253297
AbstractTensorRepresentation{U}
254-
array(atr::AbstractTensorRepresentation)
255-
array(amr::AbstractMatrixRepresentation)
298+
AbstractMatrixRepresentation{T,U}
256299
```
257300

258-
301+
### Traits
302+
```@docs
303+
IsWeighted{X}
304+
IsMeta{X}
305+
```
259306

260307

261308
```@docs

src/abstractmultilayerdigraph.jl

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,11 @@ function set_weight!(mg::M, src::MultilayerVertex, dst::MultilayerVertex, weight
149149
end
150150

151151
"""
152-
set_metadata!(mg::M, src::MultilayerVertex{L1}, dst::MultilayerVertex{L2}, metadata::U) where {L1 <: Symbol, L2 <: Symbol, T,U, M <: AbstractMultilayerGraph{T,U}}
152+
set_metadata!(mg::AbstractMultilayerDiGraph, src::MultilayerVertex, dst::MultilayerVertex, metadata::Union{Tuple, NamedTuple})
153153
154154
Set the metadata of the edge between `src` and `dst` to `metadata`. Return true if succeeds (i.e. if the edge exists and the underlying graph chosen for the Layer/Interlayer where the edge lies supports metadata at the edge level under the `IsMeta` trait).
155155
"""
156-
function set_metadata!(mg::M, src::MultilayerVertex, dst::MultilayerVertex, metadata::Union{Tuple, NamedTuple}) where M <: AbstractMultilayerDiGraph
156+
function set_metadata!(mg::AbstractMultilayerDiGraph, src::MultilayerVertex, dst::MultilayerVertex, metadata::Union{Tuple, NamedTuple})
157157
# Get the subgraph descriptor that corresponds to the layer of src and dst
158158
descriptor = get_subgraph_descriptor(mg, layer(src), layer(dst))
159159
# If the subgraph descriptor's null graph is true, then the edge does not exist
@@ -198,8 +198,14 @@ end
198198

199199
# Layers and Interlayers
200200
"""
201-
add_layer!(mg::M,layer::L; interlayers_type = "multiplex") where { T, U, G<: AbstractGraph{T}, M <: AbstractMultilayerDiGraph{T, U}, L <: Layer{T,U,G}}
202-
Add layer `layer` to `mg`.
201+
add_layer!(
202+
mg::M,
203+
new_layer::L;
204+
default_interlayers_null_graph::H = SimpleGraph{T}(),
205+
default_interlayers_structure::String ="multiplex"
206+
) where {T,U,G<:AbstractGraph{T},M<:AbstractMultilayerDiGraph{T,U},L<:Layer{T,U,G}, H <: AbstractGraph{T}}
207+
208+
Add layer `layer` to `mg`.
203209
204210
# ARGUMENTS
205211
@@ -222,7 +228,10 @@ function add_layer!(
222228
end
223229

224230
"""
225-
specify_interlayer!(mg::M, new_interlayer::In; symmetric_interlayer_name::String) where { T, U, G<: AbstractGraph{T}, M <: AbstractMultilayerDiGraph{T, U}, In <: Interlayer{T,U,G}}
231+
specify_interlayer!(
232+
mg::M,
233+
new_interlayer::In
234+
) where {T,U,G<:AbstractGraph{T},M<:AbstractMultilayerDiGraph{T,U},In<:Interlayer{T,U,G}}
226235
227236
Specify the interlayer `new_interlayer` as part of `mg`.
228237
"""

src/abstractmultilayergraph.jl

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ nodes(mg::AbstractMultilayerGraph) = [couple[2] for couple in sort(collect(mg.id
4444
4545
Return the number of nodes in `mg`.
4646
"""
47-
nn(mg::M) where {M<:AbstractMultilayerGraph} = length(nodes(mg))
47+
nn(mg::AbstractMultilayerGraph) = length(nodes(mg))
4848

4949
"""
5050
has_node(mg::AbstractMultilayerGraph, n::Node)
@@ -54,11 +54,11 @@ Return true if `n` is a node of `mg`.
5454
has_node(mg::AbstractMultilayerGraph, n::Node) = n in image(mg.idx_N_associations)
5555

5656
"""
57-
add_node!(mg::M, n::Node) where {T,U, M <: AbstractMultilayerGraph{T,U}}
57+
add_node!(mg::AbstractMultilayerGraph, n::Node)
5858
5959
Add node `n` to `mg`. Return true if succeeds.
6060
"""
61-
function add_node!(mg::M, n::Node) where {T,U, M <: AbstractMultilayerGraph{T,U}}
61+
function add_node!(mg::AbstractMultilayerGraph, n::Node)
6262
!has_node(mg, n) || return false
6363

6464
maximum_idx = isempty(domain(mg.idx_N_associations)) ? 0 : maximum(domain(mg.idx_N_associations))
@@ -70,11 +70,11 @@ function add_node!(mg::M, n::Node) where {T,U, M <: AbstractMultilayerGraph{T,U
7070
end
7171

7272
"""
73-
rem_node!(mg::M, n::Node) where {T,U, M <: AbstractMultilayerGraph{T,U}}
73+
rem_node!(mg::AbstractMultilayerGraph, n::Node)
7474
7575
Remove node `n` to `mg`. Return true if succeeds.
7676
"""
77-
function rem_node!(mg::M, n::Node) where {T,U, M <: AbstractMultilayerGraph{T,U}}
77+
function rem_node!(mg::AbstractMultilayerGraph, n::Node)
7878
has_node(mg, n) || return false
7979

8080
idx_tbr = mg.idx_N_associations(n)
@@ -145,11 +145,12 @@ Return the metadata associated to `MultilayerVertex` mv (regardless of metadata
145145
get_metadata(mg::AbstractMultilayerGraph, mv::MultilayerVertex) = mg.v_metadata_dict[get_v(mg, mv)]
146146

147147
"""
148-
set_metadata!(mg::M, mv::MultilayerVertex, metadata::Union{Tuple, NamedTuple}) where M <: AbstractMultilayerGraph
148+
set_metadata!(mg::AbstractMultilayerGraph, mv::MultilayerVertex, metadata::Union{Tuple, NamedTuple})
149149
150150
Set the metadata of vertex `mv` to `metadata`. Return true if succeeds
151151
"""
152-
function set_metadata!(mg::M, mv::MultilayerVertex, metadata::Union{Tuple, NamedTuple}) where M <: AbstractMultilayerGraph
152+
function set_metadata!(mg::AbstractMultilayerGraph, mv::MultilayerVertex, metadata::Union{Tuple, NamedTuple})
153+
153154
descriptor = mg.layers[get_layer_idx(mg, layer(mv))]#get_subgraph_descriptor(mg, layer(mv))
154155
is_meta(descriptor.null_graph) || return false
155156
has_vertex(mg, mv) || return false
@@ -248,18 +249,18 @@ SimpleWeightedGraphs.get_weight(mg::AbstractMultilayerGraph, src::MultilayerVert
248249
# Layers and Interlayers
249250

250251
"""
251-
nl(mg::M) where {M <: AbstractMultilayerGraph }
252+
nl(mg::AbstractMultilayerGraph)
252253
253254
Return the number of layers in `mg`.
254255
"""
255-
nl(mg::M) where {M<:AbstractMultilayerGraph} = length(mg.layers)
256+
nl(mg::AbstractMultilayerGraph) = length(mg.layers)
256257

257258
"""
258-
nIn(mg::M) where {M <: AbstractMultilayerGraph }
259+
nIn(mg::AbstractMultilayerGraph)
259260
260261
Return the number of interlayers in `mg`.
261262
"""
262-
nIn(mg::M) where {M<:AbstractMultilayerGraph} = length(mg.interlayers)
263+
nIn(mg::AbstractMultilayerGraph) = length(mg.interlayers)
263264

264265
"""
265266
has_layer(mg::AbstractMultilayerGraph, layer_name::Symbol)

src/abstractmultilayerugraph.jl

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,11 @@ end
136136

137137

138138
"""
139-
set_metadata!(mg::M, src::MultilayerVertex{L1}, dst::MultilayerVertex{L2}, metadata::U) where {L1 <: Symbol, L2 <: Symbol, T,U, M <: AbstractMultilayerGraph{T,U}}
139+
set_metadata!(mg::AbstractMultilayerUGraph, src::MultilayerVertex, dst::MultilayerVertex, metadata::Union{Tuple, NamedTuple})
140140
141141
Set the metadata of the edge between `src` and `dst` to `metadata`. Return true if succeeds (i.e. if the edge exists and the underlying graph chosen for the Layer/Interlayer where the edge lies supports metadata at the edge level under the `IsMeta` trait).
142142
"""
143-
function set_metadata!(mg::M, src::MultilayerVertex, dst::MultilayerVertex, metadata::Union{Tuple, NamedTuple}) where M <: AbstractMultilayerUGraph
143+
function set_metadata!(mg::AbstractMultilayerUGraph, src::MultilayerVertex, dst::MultilayerVertex, metadata::Union{Tuple, NamedTuple})
144144
descriptor = get_subgraph_descriptor(mg, layer(src), layer(dst))
145145
is_meta(descriptor.null_graph) || return false
146146
has_edge(mg, src, dst) || return false
@@ -188,7 +188,11 @@ end
188188

189189
# Layers and Interlayers
190190
"""
191-
add_layer!(mg::M,layer::L; interlayers_type = "multiplex") where { T, U, G<: AbstractGraph{T}, M <: AbstractMultilayerUGraph{T, U}, L <: Layer{T,U,G}}
191+
add_layer!( mg::M,
192+
new_layer::L;
193+
default_interlayers_null_graph::H = SimpleGraph{T}(),
194+
default_interlayers_structure::String ="multiplex"
195+
) where {T,U,G<:AbstractGraph{T},M<:AbstractMultilayerUGraph{T,U},L<:Layer{T,U,G}, H <: AbstractGraph{T}}
192196
193197
Add layer `layer` to `mg`.
194198
@@ -213,7 +217,10 @@ function add_layer!(
213217
end
214218

215219
"""
216-
specify_interlayer!(mg::M, new_interlayer::In; symmetric_interlayer_name::String) where { T, U, G<: AbstractGraph{T}, M <: AbstractMultilayerUGraph{T, U}, In <: Interlayer{T,U,G}}
220+
specify_interlayer!(
221+
mg::M,
222+
new_interlayer::In
223+
) where {T,U,G<:AbstractGraph{T},M<:AbstractMultilayerUGraph{T,U},In<:Interlayer{T,U,G}}
217224
218225
Specify the interlayer `new_interlayer` as part of `mg`.
219226
"""

0 commit comments

Comments
 (0)