You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/abstractmultilayergraph.jl
+29-37Lines changed: 29 additions & 37 deletions
Original file line number
Diff line number
Diff line change
@@ -107,7 +107,7 @@ Base.eltype(::M) where {T,M<:AbstractMultilayerGraph{T}} = T
107
107
108
108
Return true if `v` is in mg, else false.
109
109
"""
110
-
Graphs.has_vertex(mg::M, v::T ) where {T, M <:AbstractMultilayerGraph{T}} = v indomain(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 indomain(mg.v_V_associations)
throw(ErrorException("The new interlayer connects two layers that are not (one or both) part of the multilayer graph. Make sure you spelled the `layer_1` and `layer_2` arguments of the `Interlayer` correctly. Available layers are $(mg.layers_names), found $(new_interlayer.layer_1) and $(new_interlayer.layer_2)."))
389
-
# ),
390
-
# )
391
-
392
-
# Check that it has the correct number of nodes on both layers
393
-
(isempty(setdiff(Set(new_interlayer.layer_1_nodes), Set(nodes(Base.getproperty(mg, new_interlayer.layer_1)))) ) &&isempty(setdiff(Set(new_interlayer.layer_2_nodes), Set(nodes(Base.getproperty(mg, new_interlayer.layer_2)))) )) ||throw(ErrorException("The nodes in the interlayer $(new_interlayer.name) do not correspond to the nodes in the respective layers $(new_interlayer.layer_1) and $(new_interlayer.layer_2). Found $( setdiff(Set(new_interlayer.layer_1_nodes), Set(nodes(Base.getproperty(mg, new_interlayer.layer_1)))) ) and $(setdiff(Set(new_interlayer.layer_2_nodes), Set(nodes(Base.getproperty(mg, new_interlayer.layer_2)))))"))
394
-
395
-
# A rem_interlayer! function may not exist since there always must be all interlayers. We then proceed to effectively remove the interlayer here
throw(ErrorException("The new interlayer connects two layers that are not (one or both) part of the multilayer graph. Make sure you spelled the `layer_1` and `layer_2` arguments of the `Interlayer` correctly. Available layers are $(mg.layers_names), found $(new_interlayer.layer_1) and $(new_interlayer.layer_2)."))
388
+
# ),
389
+
# )
406
390
407
-
for edge inedges(new_interlayer)
408
-
success =add_edge!(mg, edge)
409
-
@assert success
410
-
end
391
+
# Check that it has the correct number of nodes on both layers
392
+
(isempty(setdiff(Set(new_interlayer.layer_1_nodes), Set(nodes(Base.getproperty(mg, new_interlayer.layer_1)))) ) &&isempty(setdiff(Set(new_interlayer.layer_2_nodes), Set(nodes(Base.getproperty(mg, new_interlayer.layer_2)))) )) ||throw(ErrorException("The nodes in the interlayer $(new_interlayer.name) do not correspond to the nodes in the respective layers $(new_interlayer.layer_1) and $(new_interlayer.layer_2). Found $( setdiff(Set(new_interlayer.layer_1_nodes), Set(nodes(Base.getproperty(mg, new_interlayer.layer_1)))) ) and $(setdiff(Set(new_interlayer.layer_2_nodes), Set(nodes(Base.getproperty(mg, new_interlayer.layer_2)))))"))
411
393
412
-
returntrue
413
-
end
394
+
# A rem_interlayer! function may not exist since there always must be all interlayers. We then proceed to effectively remove the interlayer here
layer_1_name ∈ mg.layers_names ||throw(ErrorException("$layer_1_name doesn't belong to the multilayer graph. Available layers are $(mg.layers_names)."))
430
426
layer_2_name ∈ mg.layers_names ||throw(ErrorException("$layer_2_name doesn't belong to the multilayer graph. Available layers are $(mg.layers_names)."))
431
427
layer_1_name != layer_2_name ||throw(ErrorException("`layer_1` argument is the same as `layer_2`. There is no interlayer between a layer and itself."))
@@ -447,14 +443,12 @@ end
447
443
Return the index of the `Layer` whose name is `layer_name` within `mg.layers`.
448
444
"""
449
445
functionget_layer_idx(mg::M, layer_name::Symbol) where {T,U,M<:AbstractMultilayerGraph{T,U}}
Return the descriptor associated to the interlayer connecting `layer_1` to `layer_2` (or to the Layer named `layer_1` if `layer_1` == `layer_2`)
464
458
"""
465
459
functionget_subgraph_descriptor(mg::M, layer_1_name::Symbol, layer_2_name::Symbol) where {T,U,M<:AbstractMultilayerGraph{T,U}}
466
-
467
460
if layer_1_name == layer_2_name
468
461
idx =get_layer_idx(mg, layer_1_name)
469
462
if!isnothing(idx)
470
463
return mg.layers[idx]
471
464
else
472
465
throw(ErrorException("The multilayer graph does not contain any Layer named $(layer_1_name). Available layers are $(mg.layers_names)."))
473
466
end
474
-
475
467
else
476
468
layer_1_name ∈ mg.layers_names ||throw(ErrorException("$layer_1_name does nto belong to the multilayer graph. Available layers are $(mg.layers_names)."))
477
469
layer_2_name ∈ mg.layers_names ||throw(ErrorException("$layer_2_name does nto belong to the multilayer graph. Available layers are $(mg.layers_names)."))
- `mg::M`: the `MultilayerGraph` which the new layer will be added to;
202
198
- `new_layer::L`: the new `Layer` to add to `mg`;
203
199
- `default_interlayers_null_graph::H = SimpleGraph{T}()`: upon addition of a new `Layer`, all the `Interlayer`s between the new and the existing `Layer`s are immediately created. This keyword argument specifies their `null_graph` See the `Layer` constructor for more information. Defaults to `SimpleGraph{T}()`;
204
-
- `default_interlayers_structure::String = "multiplex"`: The structure of the `Interlayer`s created by deafault. May either be "multiplex" to have diagonally-coupled only interlayers, or "empty" for empty interlayers. Defaults to "multiplex".
200
+
- `default_interlayers_structure::String = "multiplex"`: The structure of the `Interlayer`s created by default. May either be "multiplex" to have diagonally-coupled only interlayers, or "empty" for empty interlayers. Defaults to "multiplex".
0 commit comments