Skip to content

Commit cfc6779

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

File tree

5 files changed

+54
-50
lines changed

5 files changed

+54
-50
lines changed

docs/src/API.md

Lines changed: 40 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ This page provides a list of exported methods organized by topic and audience. M
44

55
## End-User
66

7-
### Nodes
7+
### [Nodes](@id nodes_eu)
88

99
```@docs
1010
Node
1111
id
1212
```
1313

14-
### Vertices
14+
### [Vertices](@id vertices_eu)
1515

1616
```@docs
1717
eltype
@@ -23,7 +23,7 @@ metadata(mv::MultilayerVertex)
2323
MissingVertex
2424
```
2525

26-
### Edges
26+
### [Edges](@id edges_eu)
2727

2828
```@docs
2929
MultilayerEdge
@@ -32,32 +32,9 @@ weight(e::AbstractMultilayerEdge)
3232
metadata(e::AbstractMultilayerEdge)
3333
```
3434

35-
### Subgraphs
35+
### [Subgraphs](@id subgraphs_eu)
3636

3737
```@docs
38-
nodes(subgraph::AbstractSubGraph)
39-
has_vertex(layer::Layer, mv::MultilayerVertex)
40-
has_vertex(interlayer::Interlayer, mv::MultilayerVertex)
41-
nv(subgraph::AbstractSubGraph)
42-
mv_vertices(subgraph::AbstractSubGraph)
43-
mv_inneighbors(subgraph::AbstractSubGraph, mv::MultilayerVertex)
44-
mv_outneighbors(subgraph::AbstractSubGraph, mv::MultilayerVertex)
45-
mv_neighbors(subgraph::AbstractSubGraph, mv::MultilayerVertex)
46-
has_edge(subgraph::AbstractSubGraph,me::MultilayerEdge)
47-
has_edge( subgraph::AbstractSubGraph, s::MultilayerVertex, d::MultilayerVertex)
48-
ne(subgraph::AbstractSubGraph)
49-
edges(subgraph::S) where {T,U,S<:AbstractSubGraph{T,U}}
50-
add_edge!( subgraph::S, me::E) where {T,U<:Real,S<:AbstractSubGraph{T,U},E<:MultilayerEdge{ <: Union{U, Nothing}}}
51-
rem_edge!(subgraph::AbstractSubGraph, src::MultilayerVertex, dst::MultilayerVertex)
52-
rem_edge!(subgraph::AbstractSubGraph, me::MultilayerEdge)
53-
get_metadata(subgraph::AbstractSubGraph, bare_mv::MultilayerVertex)
54-
get_metadata(subgraph::AbstractSubGraph, src::MultilayerVertex, dst::MultilayerVertex)
55-
get_weight(subgraph::AbstractSubGraph, src::MultilayerVertex, dst::MultilayerVertex)
56-
is_directed(subgraph::AbstractSubGraph)
57-
is_directed(::Type{S}) where {T,U,G,S <: AbstractSubGraph{T,U,G}}
58-
adjacency_matrix(subgraph::AbstractSubGraph)
59-
MultilayerGraphs.weights(subgraph::S) where {T,U,S<:AbstractSubGraph{T,U}}
60-
name(subgraph::AbstractSubGraph)
6138
Layer{T <: Integer, U <: Real, G <: AbstractGraph{T}}
6239
Layer(name::Symbol, vertices::Vector{<: MultilayerVertex}, edge_list::Vector{ <: MultilayerEdge}, null_graph::G, weighttype::Type{U}; default_vertex_metadata::Function = mv -> NamedTuple(), default_edge_weight::Function = (src, dst) -> one(U), default_edge_metadata::Function = (src, dst) -> NamedTuple()) where {T <: Integer, U <: Real, G <: AbstractGraph{T}}
6340
@@ -123,8 +100,32 @@ empty_interlayer(
123100
default_edge_metadata::Function = (x,y) -> NamedTuple(),
124101
name::Symbol = Symbol("interlayer_$(layer_1.name)_$(layer_2.name)"),
125102
transfer_vertex_metadata::Bool = false
126-
) where {T<:Integer, U <: Real, G<:AbstractGraph{T}}
103+
) where {T<:Integer, U <: Real, G<:AbstractGraph{T}}
127104
105+
nodes(subgraph::AbstractSubGraph)
106+
has_vertex(layer::Layer, mv::MultilayerVertex)
107+
has_vertex(interlayer::Interlayer, mv::MultilayerVertex)
108+
nv(subgraph::AbstractSubGraph)
109+
mv_vertices(subgraph::AbstractSubGraph)
110+
mv_inneighbors(subgraph::AbstractSubGraph, mv::MultilayerVertex)
111+
mv_outneighbors(subgraph::AbstractSubGraph, mv::MultilayerVertex)
112+
mv_neighbors(subgraph::AbstractSubGraph, mv::MultilayerVertex)
113+
has_edge(subgraph::AbstractSubGraph,me::MultilayerEdge)
114+
has_edge( subgraph::AbstractSubGraph, s::MultilayerVertex, d::MultilayerVertex)
115+
ne(subgraph::AbstractSubGraph)
116+
edges(subgraph::S) where {T,U,S<:AbstractSubGraph{T,U}}
117+
add_edge!( subgraph::S, me::E) where {T,U<:Real,S<:AbstractSubGraph{T,U},E<:MultilayerEdge{ <: Union{U, Nothing}}}
118+
rem_edge!(subgraph::AbstractSubGraph, src::MultilayerVertex, dst::MultilayerVertex)
119+
rem_edge!(subgraph::AbstractSubGraph, me::MultilayerEdge)
120+
get_metadata(subgraph::AbstractSubGraph, bare_mv::MultilayerVertex)
121+
get_metadata(subgraph::AbstractSubGraph, src::MultilayerVertex, dst::MultilayerVertex)
122+
get_weight(subgraph::AbstractSubGraph, src::MultilayerVertex, dst::MultilayerVertex)
123+
is_directed(subgraph::AbstractSubGraph)
124+
is_directed(::Type{S}) where {T,U,G,S <: AbstractSubGraph{T,U,G}}
125+
adjacency_matrix(subgraph::AbstractSubGraph)
126+
MultilayerGraphs.weights(subgraph::S) where {T,U,S<:AbstractSubGraph{T,U}}
127+
name(subgraph::AbstractSubGraph)
128+
128129
is_multiplex_interlayer(interlayer::Interlayer)
129130
130131
get_symmetric_interlayer(
@@ -133,7 +134,7 @@ get_symmetric_interlayer(
133134
) where {T,U,G,In<:Interlayer{T,U,G}}
134135
```
135136

136-
### Multilayer-Specific Methods
137+
### [Multilayer-Specific Methods](@id msm_eu)
137138

138139
```@docs
139140
MultilayerGraph{T,U}
@@ -290,7 +291,7 @@ modularity(
290291
von_neumann_entropy(mg::M) where {T,U,M<:AbstractMultilayerUGraph{T,U}}
291292
```
292293

293-
### Representations
294+
### [Representations](@id representations_eu)
294295
```@docs
295296
array(atr::AbstractTensorRepresentation)
296297
WeightTensor{U}
@@ -302,7 +303,7 @@ SupraWeightMatrix{T,U}
302303
supra_weight_matrix(mg::M) where {T,U, M <: AbstractMultilayerGraph{T,U}}
303304
```
304305

305-
### Traits
306+
### [Traits](@id traits_eu)
306307
```@docs
307308
is_weighted(g::G) where { G <: AbstractGraph}
308309
is_weighted(g::G) where {G<:Type{<:AbstractGraph}}
@@ -311,7 +312,7 @@ is_meta(g::G) where {G <: AbstractGraph}
311312
is_meta(g::G) where {G<:Type{<:AbstractGraph}}
312313
```
313314

314-
### Utilities
315+
### [Utilities](@id utilities_eu)
315316
```@docs
316317
multilayer_kronecker_delta(dims::NTuple{4,Int64})
317318
δk{T}
@@ -325,23 +326,23 @@ multilayer_kronecker_delta(dims::NTuple{4,Int64})
325326

326327
## Developer
327328

328-
### Nodes
329+
### [Nodes](@id nodes_dev)
329330

330331
```@docs
331332
AbstractNode
332333
```
333334

334335

335336

336-
### Vertices
337+
### [Vertices](@id vertices_dev)
337338

338339
```@docs
339340
AbstractVertex
340341
AbstractMultilayerVertex
341342
```
342343

343344

344-
### Edges
345+
### [Edges](@id edges_dev)
345346

346347

347348
```@docs
@@ -350,7 +351,7 @@ metadata(he::MultilayerGraphs.HalfEdge)
350351
weight(he::MultilayerGraphs.HalfEdge)
351352
```
352353

353-
### Subgraphs
354+
### [Subgraphs](@id subgraphs_dev)
354355

355356
```@docs
356357
has_vertex(subgraph::S, v::T ) where {T,S<:AbstractSubGraph{T}}
@@ -372,7 +373,7 @@ AbstractInterlayer
372373
```
373374

374375

375-
### Multilayer-Specific Methods
376+
### [Multilayer-Specific Methods](@id msm_dev)
376377

377378
```@docs
378379
AbstractMultilayerGraph{T <: Integer, U <: Real}
@@ -391,13 +392,13 @@ AbstractMultilayerUGraph{T,U}
391392
AbstractMultilayerDiGraph{T,U}
392393
```
393394

394-
### Representations
395+
### [Representations](@id representations_dev)
395396
```@docs
396397
AbstractTensorRepresentation{U}
397398
AbstractMatrixRepresentation{T,U}
398399
```
399400

400-
### Traits
401+
### [Traits](@id traits_dev)
401402
```@docs
402403
IsWeighted{X}
403404
IsMeta{X}

docs/src/index.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ A multilayer graph is composed of *layers*, i.e. graphs whose vertices represent
2626

2727
`MultilayerGraph` and `MultilayerDiGraph` support the specification of vertex and edge metadata, provided that the underlying layer or interlayer also supports metadata.
2828

29+
The documentation is organized as follows: you will find a comprehensive [Tutorial](@ref) below, complemented by an [API](@ref) page. The API page is organized in two sections: the [End-User](@ref) section lists all the methods intended for the user who does not need to write code that is also compatible with other libraries in the Graphs.jl's ecosystem, while the [Developer](@ref) section contains methods that allow MultilayerGraphs.jl to be used as any package that extend Graphs.jl . Bot section are further stratified by topic.
30+
The tutorial below will be focused on the end-used experience, as developer methods often have very similar signature and will be better addressed in a future developer-oriented guide, should the community manifest the need of it.
31+
2932
## Installation
3033

3134
Press `]` in the Julia REPL and then
@@ -105,7 +108,7 @@ multilayervertices_meta[1]
105108
MV(Node("node_1"), :nothing, ("I'm node node_1",))
106109
```
107110

108-
Where `MV` is an alias for `MultilayerVertex`. The first field is the `Node` being represented (accessible via the [`node`](@ref) function), the second the (name of) the layer the vertex is represented in ((accessible via the [`layer`](@ref) function), here it is set to `nothing`, since these vertices are yet to be assigned), and the metadata associated to the vertex ((accessible via the [`metadata`](@ref) function), no metadata are currently represented via an empty `NamedTuple`). `MultilayerVertex` metadata can be represented via a `Tuple` or a `NamedTuple` (see below for examples).
111+
Where `MV` is an alias for `MultilayerVertex`. The first field is the `Node` being represented (accessible via the [`node`](@ref) function), the second the (name of) the layer the vertex is represented in ((accessible via the [`layer`](@ref) function), here it is set to `nothing`, since these vertices are yet to be assigned), and the metadata associated to the vertex ((accessible via the [`metadata`](@ref) function), no metadata are currently represented via an empty `NamedTuple`). `MultilayerVertex` metadata can be represented via a `Tuple` or a `NamedTuple` (see below for examples). For a complete list of methods applicable to `MultilayerVertices`, plese refer to the [Vertices](@ref vertices_eu) of the API.
109112

110113
### Layers
111114

@@ -125,7 +128,7 @@ Layer(
125128
)
126129
```
127130

128-
A `Layer` is considered "weighted" if its underlying graph (`null_graph` argument) has been given the `IsWeighted` trait (traits throughout this package are implemented via from [SimpleTraits.jl](https://github.com/mauro3/SimpleTraits.jl), just like Graphs.jl does). Since one may at any moment add a new weighted `Layer` to a `MultilayerGraph` (see below for details), the latter is always considered a "weighted graph", so it is given the `IsWeighted` trait. Thus, all `Layer`s and `Interlayer`s (collectively named "subgraphs" hereafter) must specify their `weighttype` as the last argument of their constructor, so the user may debug their weight matrices immediately after construction. As better specified below, all subgraphs that are meant to be part of the same `MultilayerGraph` must have the same `weighttype`.
131+
A `Layer` is considered "weighted" if its underlying graph (`null_graph` argument) has been given the `IsWeighted` trait (traits throughout this package are implemented via [SimpleTraits.jl](https://github.com/mauro3/SimpleTraits.jl), just like Graphs.jl does). Since one may at any moment add a new weighted `Layer` to a `MultilayerGraph` (see below for details), the latter is always considered a "weighted graph", so it is given the `IsWeighted` trait. Thus, all `Layer`s and `Interlayer`s (collectively named "subgraphs" hereafter) must specify their `weighttype` as the last argument of their constructor, so the user may debug their weight matrices immediately after construction. As better specified below, all subgraphs that are meant to be part of the same `MultilayerGraph` must have the same `weighttype`.
129132

130133
Before instantiating `Layer`s, we define an utility function to ease randomization:
131134

@@ -204,7 +207,7 @@ layer_vg = Layer( :layer_vg,
204207
layers = [layer_sg, layer_swg, layer_mg, layer_vg]
205208
```
206209

207-
The API that inspects and modifies `Layer`s will be shown below together with that of `Interlayer`s, since they are usually the same. There are of course other constructors that you may discover by typing `?Layer` in the console.
210+
The API that inspects and modifies `Layer`s will be shown below together with that of `Interlayer`s, since they are usually the same. There are of course other constructors that you may discover by typing `?Layer` in the console.
208211

209212
### Interlayers
210213

@@ -296,15 +299,15 @@ interlayer_empty_sg_vg = empty_interlayer( layer_sg,
296299
interlayers = [interlayer_sg_swg, interlayer_swg_mg, interlayer_mg_vg, interlayer_multiplex_sg_mg, interlayer_empty_sg_vg]
297300
```
298301

299-
Next, we explore the API associated to modify and analyze `Layer`s and `Interlayer`s.
302+
Next, we explore the API associated to modify and analyze `Layer`s and `Interlayer`s. A complete list of methods relating to subgraphs can be found [here](@ref subgraphs_eu).
300303

301304
### Subgraphs API
302305

303306
API for `Layer`s and `Interlayer`s (collectively, "subgraphs") are very similar, so we will just show them for the `Layer` case, pointing out differences to the `Interlayer` scenario whenever they occur.
304307

305308
Subgraphs extend the Graphs.jl's interface, so one may expect every method from Graphs.jl to apply. Anyway, the output and signature is slightly different and thus worth pointing out below.
306309

307-
#### Nodes
310+
#### [Nodes](@ref nodes_tut_subg)
308311

309312
One may retrieve the `Node`s that a `Layer` represents via:
310313

@@ -346,7 +349,7 @@ has_node(layer_sg, layer_sg_nodes[1])
346349
true
347350
```
348351

349-
#### Vertices
352+
#### [Vertices](@ref vertices_tut_subg)
350353

351354
One may retrieve the `MultilayerVertex`s of a layer by calling:
352355

@@ -456,7 +459,7 @@ By design, one may not add nor remove vertices to `Interlayer`s.
456459

457460
Please refer to the Vertex section of the API page ([end-user]() and [developer]()) to discover more methods related to `MultilayerVertex`s.
458461

459-
### Edges
462+
### [Edges](@ref edges_tut_subg)
460463

461464
The edge type for multilayer graphs (and thus for this subgraphs) is `MultilayerEdge`, which has a type parameter corresponding to the chosen weight type:
462465

@@ -657,7 +660,7 @@ Note that this is not an implementation of a fully-fledged configuration model,
657660

658661
There is a similar constructor for `MultilayerDiGraph` which requires both the indegree distribution and the outdegree distribution. Anyway due to current performance limitations in the graph realization algorithms, it is suggested to provide two "similar" distributions (similar mean or location parameter, similar variance or shape parameter), in order not to incur in lengthy computational times.
659662

660-
#### Nodes
663+
#### [Nodes](@ref nodes_tut_multig)
661664

662665
You may add a node via `add_node`:
663666

src/MultilayerGraphs.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export
7575
AbstractLayer,
7676
Layer,
7777
has_node,
78-
add_vertex!
78+
add_vertex!,
7979
rem_vertex!,
8080
# interlayer.jl
8181
AbstractInterlayer,

src/subgraphs/interlayer.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ abstract type AbstractInterlayer{T,U,G} <: AbstractSubGraph{T,U,G} end
1717
"""
1818
Interlayer{T<:Integer,U<:Real,G<:AbstractGraph{T}} <: AbstractInterlayer{T,U,G}
1919
20-
Represents an interlayer in a `Multilayer(Di)Graph`.
20+
Represents an interlayer in a `Multilayer(Di)Graph`. Its type hierarchy is: Interlayer <: AbstractInterlayer <: AbstractSubGraph .
2121
"""
2222
mutable struct Interlayer{T<:Integer,U<:Real,G<:AbstractGraph{T}} <:
2323
AbstractInterlayer{T,U,G}

src/subgraphs/layer.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ abstract type AbstractLayer{T,U,G} <: AbstractSubGraph{T,U,G} end
1717
"""
1818
mutable struct Layer{T <: Integer, U <: Real, G <: AbstractGraph{T}} <: AbstractLayer{T,U,G}
1919
20-
Represents a layer in a `Multilayer(Di)Graph`.
20+
Represents a layer in a `Multilayer(Di)Graph`. Its type hierarchy is: Layer <: AbstractLayer <: AbstractSubGraph .
2121
"""
2222
mutable struct Layer{T<:Integer,U<:Real,G<:AbstractGraph{T}} <: AbstractLayer{T,U,G}
2323
descriptor::LayerDescriptor{T,U,G}

0 commit comments

Comments
 (0)