Skip to content

Commit a8a8591

Browse files
InterdisciplinaryPhysicsTeampitmonticoneClaudMor
committed
Update docstrings, minor fixes
Co-Authored-By: Pietro Monticone <[email protected]> Co-Authored-By: Claudio Moroni <[email protected]>
1 parent 171fa2b commit a8a8591

File tree

9 files changed

+46
-47
lines changed

9 files changed

+46
-47
lines changed

docs/src/API.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ nodes(::AbstractSubGraph)
4343
has_vertex(layer::L, v::MultilayerVertex) where { T,U,G, L <: Layer{T,U,G}}
4444
has_vertex(interlayer::In, v::MultilayerVertex) where { T,U,G, In <: Interlayer{T,U,G}}
4545
nv(subgraph::S) where { S <: AbstractSubGraph}
46-
mv_vertices(subgraph::S) where {S <: AbstractSubGraph{ <: Integer, <: AbstractSimpleGraph}}
46+
mv_vertices(subgraph::S) where {S<:AbstractSubGraph}
4747
```
4848

4949
### Multilayer-specific methods
@@ -84,15 +84,15 @@ AbstractMultilayerVertex
8484

8585
```@docs
8686
AbstractMultilayerEdge
87-
metadata(he::HalfEdge)
88-
weight(he::HalfEdge)
87+
metadata(he::MultilayerGraphs.HalfEdge)
88+
weight(he::MultilayerGraphs.HalfEdge)
8989
```
9090

9191
# Subgraphs
9292

9393
```@docs
9494
has_vertex(subgraph::S, v::T ) where {T,U,G,S<:AbstractSubGraph{T,U,G}}
95-
vertices(subgraph::S) where {S <: AbstractSubGraph{ <: Integer, <: AbstractSimpleGraph}}
95+
vertices(subgraph::S) where {S <: AbstractSubGraph{ <: Integer, <: AbstractGraph}}
9696
inneighbors(subgraph::S, v::T) where {T,U,G, S <: AbstractSubGraph{T,U,G}}
9797
inneighbors(subgraph::S, mv::MultilayerVertex) where {T,U,G, S <: AbstractSubGraph{T,U,G}}
9898
```
@@ -107,7 +107,7 @@ inneighbors(subgraph::S, mv::MultilayerVertex) where {T,U,G, S <: AbstractSubGr
107107
has_vertex(mg::M, v::T) where {T,U, M <: AbstractMultilayerGraph{T,U}}
108108
vertices(mg::M) where {M<:AbstractMultilayerGraph}
109109
inneighbors(mg::M, v::T) where {M <: AbstractMultilayerUGraph{T} } where { T <: Integer}
110-
inneighbors(mg::M, v::T) where {M <: AbstractMultilayerDirDiGraph{T} } where { T <: Integer}
110+
inneighbors(mg::M, v::T) where {M <: AbstractMultilayerDiGraph{T} } where { T <: Integer}
111111
inneighbors( mg::M, mv::V ) where {T,M<:AbstractMultilayerGraph{T,<:Real},V<:MultilayerVertex}
112112
```
113113

src/MultilayerGraphs.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export
4646
# layerdescriptor.jl
4747
# interlayerdescriptor.jl
4848
# abstractsubgraph.jl
49+
AbstractSubGraph,
4950
nodes,
5051
eltype,
5152
has_vertex,
@@ -132,6 +133,7 @@ export
132133
specify_interlayer!,
133134
von_neumann_entropy,
134135
# abstractmultilayerdigraph.jl
136+
AbstractMultilayerDiGraph,
135137
# multilayergraph.jl
136138
MultilayerGraph,
137139
fadjlist,
@@ -153,7 +155,6 @@ using Distributions: Uniform
153155
using LinearAlgebra, Statistics, OMEinsum, TensorOperations, Distributions
154156
using DataStructures, SparseArrays
155157
using Graphs, SimpleWeightedGraphs, MetaGraphs, SimpleValueGraphs
156-
using Agents
157158

158159

159160

src/abstractmultilayergraph.jl

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ abstract type AbstractMultilayerGraph{T<:Integer,U<:Real} <: AbstractGraph{T} en
3737
3838
Return the nodes of the AbstractMultilayerGraph `mg`, in order of addition.
3939
"""
40-
nodes(mg::M) where {M<:AbstractMultilayerGraph} = [couple[2] for couple in sort(collect(mg.idx_N_associations), by = first)]
40+
nodes(mg::AbstractMultilayerGraph) = [couple[2] for couple in sort(collect(mg.idx_N_associations), by = first)]
4141

4242
"""
4343
nn(mg::M) where {M <: AbstractMultilayerGraph }
@@ -95,19 +95,19 @@ end
9595

9696
# Vertices
9797
"""
98-
Base.eltype(mg::M) where {M <: AbstractMultilayerGraph}
98+
eltype(::M) where {T,M<:AbstractMultilayerGraph{T}}
9999
100100
Return the vertex type of `mg`.
101101
"""
102-
Base.eltype(::M) where {T,U,M<:AbstractMultilayerGraph{T,U}} = T
102+
Base.eltype(::M) where {T,M<:AbstractMultilayerGraph{T}} = T
103103

104104

105105
"""
106-
has_vertex(mg::M, v::T) where {T,U, M <: AbstractMultilayerGraph{T,U}}
106+
has_vertex(mg::M, v::T) where {T,M <: AbstractMultilayerGraph{T}}
107107
108108
Return true if `v` is in mg, else false.
109109
"""
110-
Graphs.has_vertex(mg::M, v::T ) where {T,U, M <: AbstractMultilayerGraph{T,U}} = v in domain(mg.v_V_associations) # && !(mg.v_V_associations[v] isa MissingVertex)
110+
Graphs.has_vertex(mg::M, v::T ) where {T, M <: AbstractMultilayerGraph{T}} = v in domain(mg.v_V_associations) # && !(mg.v_V_associations[v] isa MissingVertex)
111111

112112
"""
113113
has_vertex(mg::M, mv::MultilayerVertex) where {T,U, M <: AbstractMultilayerGraph{T,U}}
@@ -128,14 +128,7 @@ mv_vertices(mg::AbstractMultilayerGraph) = [get_rich_mv(mg, v) for v in vertic
128128
129129
Return the number of vertices in `mg`, excluding the missing vertices.
130130
"""
131-
Graphs.nv(mg::M) where {M<:AbstractMultilayerGraph} = length(mg.v_V_associations) #length([mv for mv in image(mg.v_V_associations) if !(mv isa MissingVertex)])
132-
133-
#= """
134-
nv_withmissing(mg::M) where {M<:AbstractMultilayerGraph}
135-
136-
Return the number of vertices of `mg`, including the missing vertices.
137-
"""
138-
nv_withmissing(mg::M) where {M<:AbstractMultilayerGraph} = length(mg.v_V_associations) =#
131+
Graphs.nv(mg::AbstractMultilayerGraph) = length(mg.v_V_associations)
139132

140133
"""
141134
vertices(mg::M) where {M<:AbstractMultilayerGraph}

src/node.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
abstract type AbstractNode end
2+
abstract type AbstractNode
33
44
An abstract type representing a node.
55
"""

src/subgraphs/abstractsubgraph.jl

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,67 @@
1+
"""
2+
abstract type AbstractSubGraph{T <: Integer,U <: Real,G <: AbstractGraph{T}}
3+
4+
An abstract type representing a subgraph (i.e. a layer or an interlayer).
5+
"""
16
abstract type AbstractSubGraph{T <: Integer,U <: Real,G <: AbstractGraph{T}} end
27

38
# Nodes
49
"""
5-
nodes(subgraph::S) where { S <: AbstractSubGraph}
10+
nodes(subgraph::AbstractSubGraph)
611
712
Return the collection of the nodes of `subgraph`.
813
"""
9-
nodes(subgraph::S) where {S<:AbstractSubGraph} = unique([mv.node for mv in mv_vertices(subgraph)])
14+
nodes(subgraph::AbstractSubGraph) = unique([mv.node for mv in mv_vertices(subgraph)])
1015

1116
# Vertices
1217
"""
13-
Base.eltype(subgraph::S) where { S <: AbstractSubGraph}
18+
Base.eltype(subgraph::AbstractSubGraph)
1419
1520
Return the vertex type of `subgraph`.
1621
"""
17-
Base.eltype(subgraph::S) where {S<:AbstractSubGraph} = typeof(subgraph).parameters[1]
22+
Base.eltype(subgraph::AbstractSubGraph) = typeof(subgraph).parameters[1]
1823

1924
"""
20-
has_vertex(subgraph::S, v::T ) where {T,U,G,S<:AbstractSubGraph{T,U,G}}
25+
has_vertex( subgraph::S, v::T ) where {T,S<:AbstractSubGraph{T}}
2126
2227
Return `true` if `v` is a vertex of `subgraph`.
2328
"""
24-
Graphs.has_vertex( subgraph::S, v::T ) where {T,U,G,S<:AbstractSubGraph{T,U,G}} = has_vertex(subgraph.graph, v)
29+
Graphs.has_vertex(subgraph::S, v::T) where {T,S<:AbstractSubGraph{T}} = has_vertex(subgraph.graph, v)
2530

2631
"""
27-
nv(subgraph::S) where { S <: AbstractSubGraph}
32+
nv(subgraph::AbstractSubGraph)
2833
2934
Return the number of vertices in `subgraph`.
3035
"""
31-
Graphs.nv(subgraph::S) where {S<:AbstractSubGraph} = nv(subgraph.graph) #length(vertices(subgraph))
36+
Graphs.nv(subgraph::AbstractSubGraph) = nv(subgraph.graph) #length(vertices(subgraph))
3237

3338
"""
34-
vertices(subgraph::S) where {S <: AbstractSubGraph{ <: Integer, <: AbstractSimpleGraph}}
39+
vertices(subgraph::AbstractSubGraph)
3540
3641
Return the collection of the vertices of `subgraph`.
3742
"""
38-
Graphs.vertices(subgraph::S) where {S<:AbstractSubGraph} = vertices(subgraph.graph)
43+
Graphs.vertices(subgraph::AbstractSubGraph) = vertices(subgraph.graph)
3944

4045
"""
41-
mv_vertices(subgraph::S) where {S <: AbstractSubGraph{ <: Integer, <: AbstractSimpleGraph}}
46+
mv_vertices(subgraph::AbstractSubGraph)
4247
4348
Return the collection of the `MultilayerVertex`s of `subgraph`.
4449
"""
45-
mv_vertices(subgraph::S) where {S<:AbstractSubGraph} = get_rich_mv.(Ref(subgraph), vertices(subgraph))
50+
mv_vertices(subgraph::AbstractSubGraph) = get_rich_mv.(Ref(subgraph), vertices(subgraph))
4651

4752
"""
48-
inneighbors(subgraph::S, v::T) where {T,U,G, S <: AbstractSubGraph{T,U,G}}
53+
inneighbors(subgraph::S, v::T) where {T, S <: AbstractSubGraph{T}}
4954
5055
Return the list of inneighbors of `v` within `subgraph`.
5156
"""
52-
Graphs.inneighbors(subgraph::S, v::T) where {T,U,G,S<:AbstractSubGraph{T,U,G}} = inneighbors(subgraph.graph, v)
57+
Graphs.inneighbors(subgraph::S, v::T) where {T,S<:AbstractSubGraph{T}} = inneighbors(subgraph.graph, v)
5358

5459
"""
55-
inneighbors(subgraph::S, mv::MultilayerVertex) where {T,U,G, S <: AbstractSubGraph{T,U,G}}
60+
inneighbors(subgraph::AbstractSubGraph, mv::MultilayerVertex)
5661
5762
Return the list of inneighbors of `mv` within `subgraph`.
5863
"""
59-
Graphs.inneighbors(subgraph::S, mv::MultilayerVertex) where {T,U,G,S<:AbstractSubGraph{T,U,G}} = inneighbors(subgraph, get_v(subgraph,mv))
64+
Graphs.inneighbors(subgraph::AbstractSubGraph, mv::MultilayerVertex) = inneighbors(subgraph, get_v(subgraph,mv))
6065

6166
"""
6267
mv_inneighbors(subgraph::AbstractSubGraph, mv::MultilayerVertex)
@@ -66,18 +71,18 @@ Return the `MultilayerVertex`s inneighbors of `mv` within `subgraph`.
6671
mv_inneighbors(subgraph::AbstractSubGraph, mv::MultilayerVertex) = get_rich_mv.(Ref(subgraph), inneighbors(subgraph,mv))
6772

6873
"""
69-
outneighbors(subgraph::S, v::T) where {T,U,G, S <: AbstractSubGraph{T,U,G}}
74+
outneighbors(subgraph::S, v::T) where {T,S<:AbstractSubGraph{T}}
7075
7176
Return the list of outneighbors of `v` within `subgraph`.
7277
"""
73-
Graphs.outneighbors(subgraph::S, v::T) where {T,U,G,S<:AbstractSubGraph{T,U,G}} = outneighbors(subgraph.graph, v)
78+
Graphs.outneighbors(subgraph::S, v::T) where {T,S<:AbstractSubGraph{T}} = outneighbors(subgraph.graph, v)
7479

7580
"""
76-
outneighbors(subgraph::S, mv::MultilayerVertex) where {T,U,G, S <: AbstractSubGraph{T,U,G}}
77-
81+
outneighbors(subgraph::AbstractSubGraph, mv::MultilayerVertex)
82+
7883
Return the list of outneighbors of `mv` within `subgraph`.
7984
"""
80-
Graphs.outneighbors(subgraph::S, mv::MultilayerVertex) where {T,U,G,S<:AbstractSubGraph{T,U,G}} = outneighbors(subgraph, subgraph.v_V_associations(get_bare_mv(mv)))
85+
Graphs.outneighbors(subgraph::AbstractSubGraph, mv::MultilayerVertex) = outneighbors(subgraph, subgraph.v_V_associations(get_bare_mv(mv)))
8186

8287
"""
8388
mv_outneighbors(subgraph::AbstractSubGraph, mv::MultilayerVertex)

src/subgraphs/interlayer.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,11 +413,11 @@ function is_multiplex_interlayer(interlayer::In) where {In<:Interlayer}
413413
end
414414

415415
"""
416-
has_vertex(interlayer::In, v::MultilayerVertex) where { T,U,G, In <: Interlayer{T,U,G}}
416+
has_vertex(interlayer::Interlayer, v::MultilayerVertex)
417417
418418
Return `true` if `v` is a vertex of `interlayer`.
419419
"""
420-
has_node( interlayer::In, n::Node ) where {T,U,G,In<:Interlayer{T,U,G}} = n in nodes(interlayer.layer_1) || n in nodes(interlayer.layer_2)
420+
has_node( interlayer::Interlayer, n::Node ) = n in nodes(interlayer.layer_1) || n in nodes(interlayer.layer_2)
421421

422422

423423
"""

src/subgraphs/layer.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,11 @@ has_node(layer::L, n::Node) where {L<:Layer} = MV(n, layer.name) ∈ image(layer
162162

163163

164164
"""
165-
has_vertex(layer::L, v::MultilayerVertex) where { T,U,G, L <: Layer{T,U,G}}
165+
has_vertex(layer::Layer, v::MultilayerVertex)
166166
167167
Return `true` if `v` is a vertex of `layer`.
168168
"""
169-
Graphs.has_vertex(layer::L, mv::MultilayerVertex) where {T,U,G,L<:Layer{T,U,G}} = MV(node(mv), name(layer)) collect(image(layer.v_V_associations))
169+
Graphs.has_vertex(layer::Layer, mv::MultilayerVertex) = MV(node(mv), name(layer)) collect(image(layer.v_V_associations))
170170

171171
# TODO:
172172
# Implement a MultilayerVertex constructor that leaves the .layer field unspecified, for ease of use of the following function

src/utilities.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ Returns a simple graph with a given finite degree sequence of non-negative integ
574574
2. [Kleitman and Wang (1973)](https://doi.org/10.1016/0012-365X(73)90037-X)
575575
"""
576576
function havel_hakimi_(empty_graph::SimpleGraph, degree_sequence::Vector{<:Integer}) # Please think about a decent name!
577-
# Check wether the given degree sequence contains only non-negative integers
577+
# Check whether the given degree sequence contains only non-negative integers
578578
!any(degree -> degree < 0, degree_sequence) || throw(ArgumentError("The degree sequence (degree_sequence) is invalid: it must contain non-negative integers only."))
579579
# Check whether the given degree sequence is compatible with the given multilayer graph
580580
nv(empty_graph) == length(degree_sequence) || throw(ArgumentError("The degree sequence (degree_sequence) and the multilayer graph (empty_mg) are incompatible: the length of the degree sequence doesn't coincide with the number of vertices."))

src/vertices/multilayervertex.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
AbstractMultilayerVertex{S}
2+
AbstractMultilayerVertex{S} <: AbstractVertex
33
44
An abstract type representing an abstract MultilayerGraph vertex.
55
"""

0 commit comments

Comments
 (0)