Skip to content

Commit f2c9e8a

Browse files
2 parents 8f9324d + b95d35f commit f2c9e8a

File tree

4 files changed

+104
-12
lines changed

4 files changed

+104
-12
lines changed

docs/src/API.md

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,63 @@ get_symmetric_interlayer(
133133
134134
```
135135

136-
### Multilayer-specific methods
136+
### Multilayer-Specific Methods
137137

138138
```@docs
139+
MultilayerGraph{T,U}
140+
141+
MultilayerDiGraph{T,U}
142+
143+
MultilayerGraph(T::Type{<:Number}, U::Type{<:Number})
144+
145+
MultilayerDiGraph(T::Type{<:Number}, U::Type{<:Number})
146+
147+
MultilayerGraph(
148+
layers::Vector{<:Layer{T,U}},
149+
specified_interlayers::Vector{<:Interlayer{T,U}};
150+
default_interlayers_null_graph::H = SimpleGraph{T}(),
151+
default_interlayers_structure::String="multiplex",
152+
) where {T,U, H <: AbstractGraph{T}}
153+
154+
MultilayerDiGraph(
155+
layers::Vector{<:Layer{T,U}},
156+
specified_interlayers::Vector{<:Interlayer{T,U}};
157+
default_interlayers_null_graph::H = SimpleGraph{T}(),
158+
default_interlayers_structure::String="multiplex",
159+
) where {T,U, H <: AbstractGraph{T}}
160+
161+
MultilayerGraph(
162+
empty_layers::Vector{<:Layer{T,U}},
163+
empty_interlayers::Vector{<:Interlayer{T,U}},
164+
degree_distribution::UnivariateDistribution;
165+
allow_self_loops::Bool = false,
166+
default_interlayers_null_graph::H = SimpleGraph{T}(),
167+
) where {T <: Integer, U <: Real, H <: AbstractGraph{T}}
168+
169+
MultilayerDiGraph(
170+
empty_layers::Vector{<:Layer{T,U}},
171+
empty_interlayers::Vector{<:Interlayer{T,U}},
172+
indegree_distribution::UnivariateDistribution,
173+
outdegree_distribution::UnivariateDistribution;
174+
allow_self_loops::Bool = false,
175+
default_interlayers_null_graph::H = SimpleGraph{T}(),
176+
) where {T <: Integer, U <: Real, H <: AbstractGraph{T}}
177+
178+
MultilayerGraph(
179+
empty_multilayergraph::MultilayerGraph{T,U},
180+
degree_sequence::Vector{<:Integer};
181+
allow_self_loops::Bool = false,
182+
perform_checks::Bool = true
183+
) where {T,U}
184+
185+
MultilayerDiGraph(
186+
empty_multilayerdigraph::MultilayerDiGraph{T,U},
187+
indegree_sequence::Vector{<:Integer},
188+
outdegree_sequence::Vector{<:Integer};
189+
allow_self_loops::Bool = false,
190+
perform_checks::Bool = false
191+
) where {T,U}
192+
139193
nodes(mg::AbstractMultilayerGraph)
140194
nn(mg::AbstractMultilayerGraph)
141195
add_node!(mg::AbstractMultilayerGraph, n::Node)
@@ -232,6 +286,8 @@ modularity(
232286
233287
234288
von_neumann_entropy(mg::M) where {T,U,M<:AbstractMultilayerUGraph{T,U}}
289+
290+
235291
```
236292

237293
### Representations

src/MultilayerGraphs.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,8 @@ export
135135
AbstractMultilayerDiGraph,
136136
# multilayergraph.jl
137137
MultilayerGraph,
138-
fadjlist,
139138
# multilayerdigraph.jl
140139
MultilayerDiGraph,
141-
badjlist,
142140
# utilities
143141
multilayer_kronecker_delta,
144142
δk,

src/multilayerdigraph.jl

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,12 @@ end
2828

2929
# Constructors
3030
"""
31-
MultilayerDiGraph(layers::Vector{ <: Layer{T,U }}, specified_interlayers::Vector{ <: Interlayer{T,U}}; default_interlayer::String = "multiplex") where {T, U}
31+
MultilayerDiGraph(
32+
layers::Vector{<:Layer{T,U}},
33+
specified_interlayers::Vector{<:Interlayer{T,U}};
34+
default_interlayers_null_graph::H = SimpleGraph{T}(),
35+
default_interlayers_structure::String="multiplex",
36+
) where {T,U, H <: AbstractGraph{T}}
3237
3338
Construct a MultilayerDiGraph with layers given by `layers`. The interlayers will be constructed by default according to `default_interlayer` where only `"multiplex"` and `"empty"` are allowed, except for those specified in `specified_interlayers`. `default_interlayer = "multiplex"` will imply that unspecified interlayers will have only diagonal couplings, while `default_interlayer = "multiplex"` will produced interlayers that have no couplings.
3439
"""
@@ -131,7 +136,14 @@ end
131136
# Multilayer-specific methods
132137
# "empty graph" could be the correct way of calling a graph with no edges: https://math.stackexchange.com/questions/320859/what-is-the-term-for-a-graph-on-n-vertices-with-no-edges
133138
"""
134-
MultilayerDiGraph(empty_layers::Vector{<:Layer{T,U}}, empty_interlayers::Vector{<:Interlayer{T,U}}, degree_distribution::UnivariateDistribution; allow_self_loops::Bool = false, default_interlayers_null_graph::H = SimpleGraph{T}() ) where {T <: Integer, U <: Real, H <: AbstractGraph{T}}
139+
MultilayerDiGraph(
140+
empty_layers::Vector{<:Layer{T,U}},
141+
empty_interlayers::Vector{<:Interlayer{T,U}},
142+
indegree_distribution::UnivariateDistribution,
143+
outdegree_distribution::UnivariateDistribution;
144+
allow_self_loops::Bool = false,
145+
default_interlayers_null_graph::H = SimpleGraph{T}(),
146+
) where {T <: Integer, U <: Real, H <: AbstractGraph{T}}
135147
136148
Return a random MultilayerDiGraph that has `empty_layers` as layers and `empty_interlayers` as specified interlayers. `empty_layers` and `empty_interlayers` must respectively be `Layer`s and `Interlayer`s with whatever number of vertices but no edges (if any edge is found, an error is thrown). The degree distribution of the returned random `MultilayerDiGraph` is given by `degree_distribution`, which must have a support that only contains positive numbers for obvious reasons. `allow_self_loops = true` allows for self loops t be present in the final random MultilayerDiGraph. `default_interlayers_null_graph` controls the `null_graph` argument passed to automatically-generated interlayers.
137149
"""
@@ -173,11 +185,23 @@ function MultilayerDiGraph(
173185
end
174186

175187
"""
176-
MultilayerDiGraph(empty_multilayerdigraph::MultilayerDiGraph{T,U}, degree_sequence::Vector{<:Integer}; allow_self_loops::Bool = false, perform_checks::Bool = false) where {T,U}
188+
MultilayerDiGraph(
189+
empty_multilayerdigraph::MultilayerDiGraph{T,U},
190+
indegree_sequence::Vector{<:Integer},
191+
outdegree_sequence::Vector{<:Integer};
192+
allow_self_loops::Bool = false,
193+
perform_checks::Bool = false
194+
) where {T,U}
177195
178196
Return a random `MultilayerDiGraph` with degree sequence `degree_sequence`. `allow_self_loops` controls the presence of self-loops, while if `perform_checks` is true, the `degree_sequence` os checked to be graphical.
179197
"""
180-
function MultilayerDiGraph(empty_multilayerdigraph::MultilayerDiGraph{T,U}, indegree_sequence::Vector{<:Integer},outdegree_sequence::Vector{<:Integer} ; allow_self_loops::Bool = false, perform_checks::Bool = false) where {T,U}
198+
function MultilayerDiGraph(
199+
empty_multilayerdigraph::MultilayerDiGraph{T,U},
200+
indegree_sequence::Vector{<:Integer},
201+
outdegree_sequence::Vector{<:Integer};
202+
allow_self_loops::Bool = false,
203+
perform_checks::Bool = false
204+
) where {T,U}
181205

182206
(allow_self_loops && perform_checks) && @warn "Checks for graphicality and coherence with the provided `empty_multilayerdigraph` are currently performed without taking into account self-loops. Thus said checks may fail event though the provided `indegree_sequence` and `outdegree_sequence` may be graphical when one allows for self-loops within the directed multilayer graph to be present. If you are sure that the provided `indegree_sequence` and `outdegree_sequence` are indeed graphical under those circumstances, you may want to disable checks by setting `perform_checks = false`. We apologize for the inconvenient."
183207

src/multilayergraph.jl

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@ end
2626

2727
# Constructors
2828
"""
29-
MultilayerGraph(layers::Vector{ <: Layer{T,U }}, specified_interlayers::Vector{ <: Interlayer{T,U}}; default_interlayer::String = "multiplex") where {T, U}
29+
MultilayerGraph(
30+
layers::Vector{<:Layer{T,U}},
31+
specified_interlayers::Vector{<:Interlayer{T,U}};
32+
default_interlayers_null_graph::H = SimpleGraph{T}(),
33+
default_interlayers_structure::String="multiplex",
34+
) where {T,U, H <: AbstractGraph{T}}
3035
3136
Construct a MultilayerGraph with layers given by `layers`. The interlayers will be constructed by default according to `default_interlayer` where only `"multiplex"` and `"empty"` are allowed, except for those specified in `specified_interlayers`. `default_interlayer = "multiplex"` will imply that unspecified interlayers will have only diagonal couplings, while `default_interlayer = "multiplex"` will produced interlayers that have no couplings.
3237
@@ -141,7 +146,13 @@ end
141146
# Multilayer-specific methods
142147
# "empty graph" could be the correct way of calling a graph with no edges: https://math.stackexchange.com/questions/320859/what-is-the-term-for-a-graph-on-n-vertices-with-no-edges
143148
"""
144-
MultilayerGraph(empty_layers::Vector{<:Layer{T,U}}, empty_interlayers::Vector{<:Interlayer{T,U}}, degree_distribution::UnivariateDistribution; allow_self_loops::Bool = false, default_interlayers_null_graph::H = SimpleGraph{T}() ) where {T <: Integer, U <: Real, H <: AbstractGraph{T}}
149+
MultilayerGraph(
150+
empty_layers::Vector{<:Layer{T,U}},
151+
empty_interlayers::Vector{<:Interlayer{T,U}},
152+
degree_distribution::UnivariateDistribution;
153+
allow_self_loops::Bool = false,
154+
default_interlayers_null_graph::H = SimpleGraph{T}(),
155+
) where {T <: Integer, U <: Real, H <: AbstractGraph{T}}
145156
146157
Return a random MultilayerGraph that has `empty_layers` as layers and `empty_interlayers` as specified interlayers. `empty_layers` and `empty_interlayers` must respectively be `Layer`s and `Interlayer`s with whatever number of vertices but no edges (if any edge is found, an error is thrown). The degree distribution of the returned random `MultilayerGraph` is given by `degree_distribution`, which must have a support that only contains positive numbers for obvious reasons. `allow_self_loops = true` allows for self loops t be present in the final random MultilayerGraph. `default_interlayers_null_graph` controls the `null_graph` argument passed to automatically-generated interlayers.
147158
"""
@@ -178,13 +189,16 @@ function MultilayerGraph(
178189
end
179190

180191
"""
181-
MultilayerGraph(empty_multilayergraph::MultilayerGraph{T,U}, degree_sequence::Vector{<:Integer}; allow_self_loops::Bool = false, perform_checks::Bool = false) where {T,U}
192+
MultilayerGraph(empty_multilayergraph::MultilayerGraph{T,U},
193+
degree_sequence::Vector{<:Integer};
194+
allow_self_loops::Bool = false,
195+
perform_checks::Bool = false) where {T,U}
182196
183197
Return a random `MultilayerGraph` with degree sequence `degree_sequence`. `allow_self_loops` controls the presence of self-loops, while if `perform_checks` is true, the `degree_sequence` os checked to be graphical.
184198
"""
185199
function MultilayerGraph(empty_multilayergraph::MultilayerGraph{T,U}, degree_sequence::Vector{<:Integer}; allow_self_loops::Bool = false, perform_checks::Bool = true) where {T,U}
186200

187-
(allow_self_loops && perform_checks) && @warn "Checks for graphicality and coherence with the provided `empty_multilayergraph` are currently performed without taking into account self-loops. Thus said checks may fail event though the provided `degree_sequence` may be graphical when one allows for self-loops within the multilayer graph to be present. If you are sure that the provided `degree_sequence` is indeed graphical under those circumstances, you may want to disable checks by setting `perform_checks = false`. We apologize for the inconvenient."
201+
(allow_self_loops && perform_checks) && @warn "Checks for graphicality and coherence with the provided `empty_multilayergraph` are currently performed without taking into account self-loops. Thus said checks may fail even though the provided `degree_sequence` may be graphical when one allows for self-loops within the multilayer graph to be present. If you are sure that the provided `degree_sequence` is indeed graphical under those circumstances, you may want to disable checks by setting `perform_checks = false`. We apologize for the inconvenient."
188202

189203
_multilayergraph = deepcopy(empty_multilayergraph)
190204

@@ -207,7 +221,7 @@ function MultilayerGraph(empty_multilayergraph::MultilayerGraph{T,U}, degree_seq
207221
end
208222

209223
"""
210-
MultilayerGraph(n_nodes::Int64, T::Type{ <: Number}, U::Type{ <: Number} )
224+
MultilayerGraph(T::Type{<:Number}, U::Type{<:Number})
211225
212226
Return a null MultilayerGraph with with vertex type `T` weighttype `U`. Use this constructor and then add Layers and Interlayers via the `add_layer!` and `specify_interlayer!` methods.
213227
"""

0 commit comments

Comments
 (0)