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
set_weight!(mg::M, src::MultilayerVertex{L1}, dst::MultilayerVertex{L2}, weight::U) where {L1 <: Symbol, L2 <: Symbol, T,U, M <: AbstractMultilayerGraph{T,U}}
136
128
137
129
Set the weight of the edge between `src` and `dst` to `weight`. Return true if succeeds (i.e. if the edge exists and the underlying graph chosen for the Layer/Interlayer where the edge lies is weighted under the `IsWeighted` trait).
138
130
"""
139
131
functionset_weight!(mg::M, src::MultilayerVertex, dst::MultilayerVertex, weight::U) where { T,U, M <:AbstractMultilayerDiGraph{T,U}}
132
+
# Get the subgraph descriptor for the layer containing both src and dst
set_metadata!(mg::M, src::MultilayerVertex{L1}, dst::MultilayerVertex{L2}, metadata::U) where {L1 <: Symbol, L2 <: Symbol, T,U, M <: AbstractMultilayerGraph{T,U}}
160
153
161
154
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).
162
155
"""
163
156
functionset_metadata!(mg::M, src::MultilayerVertex, dst::MultilayerVertex, metadata::Union{Tuple, NamedTuple}) where M <:AbstractMultilayerDiGraph
157
+
# Get the subgraph descriptor that corresponds to the layer of src and dst
# Overloads that make AbstractMultilayerDiGraph an extension of Graphs.jl. These are all well-inferred .
182
175
"""
183
176
edges(mg::M) where {T,U,M<:AbstractMultilayerDiGraph{T,U}}
@@ -389,18 +382,19 @@ end
389
382
return _inneighbors
390
383
end
391
384
392
-
393
-
# function get_overlay_monoplex_graph end #approach taken from https://github.com/JuliaGraphs/Graphs.jl/blob/7152d540631219fd51c43ab761ec96f12c27680e/src/core.jl#L124
394
385
"""
395
386
get_overlay_monoplex_graph(mg::M) where {M<: AbstractMultilayerDiGraph}
396
387
Get overlay monoplex graph (i.e. the graph that has the same nodes as `mg` but the link between node `i` and `j` has weight equal to the sum of all edges weights between the various vertices representing `i` and `j` in `mg`, accounting for both layers and interlayers). See [De Domenico et al. (2013)](https://doi.org/10.1103/PhysRevX.3.041022).
397
388
"""
398
389
functionget_overlay_monoplex_graph(mg::M) where {T,U,M<:AbstractMultilayerDiGraph{T,U}}
390
+
# Convert the multilayer graph to a weight tensor
399
391
wgt =weight_tensor(mg).array
392
+
# Sum the weights for each edge in the multilayer graph
400
393
projected_overlay_adjacency_matrix =sum([
401
394
wgt[:, :, i, i] for i in1:size(wgt, 3)
402
395
])
403
396
returnSimpleWeightedDiGraph{T,U}(
404
397
projected_overlay_adjacency_matrix
405
398
)
399
+
# Approach taken from https://github.com/JuliaGraphs/Graphs.jl/blob/7152d540631219fd51c43ab761ec96f12c27680e/src/core.jl#L124
Check if `graph`, whose vertices are interpreted via `v_V_associations` can be the underlying bipartite graph of an Interlayer graph.
453
451
"""
454
452
functionis_interlayer_bipartite(graph::G, v_V_associations::Bijection{T, MultilayerVertex}) where {T, G <:AbstractGraph{T}}
455
-
456
453
layers =unique([mv.layer for mv inimage(v_V_associations)])
457
454
# If it is an empty interlayer, we assume it is bipartite
458
455
length(layers) ==0&&returntrue
459
456
length(layers) ==2||throw(ErrorException("The interlayer cannot be bipartite since more than two layers are involved. Found $layers in v_V_associations."))
457
+
# This loop iterates through all edges of the graph
460
458
for edge inedges(graph)
459
+
# This if statement checks if the source and destination of the edge are on the same layer
elseif f ∈ (:name, :layer_1, :layer_2, :null_graph, :default_edge_weight, :default_edge_metadata, :transfer_vertex_metadata)
552
552
Base.getfield(interlayer.descriptor, f)
553
553
elseif f ==:edge_list
554
554
edges(interlayer)
@@ -578,19 +578,19 @@ end
578
578
"""
579
579
get_symmetric_interlayer(interlayer::In; symmetric_interlayer_name::String) where{T,U,G, In <: Interlayer{T,U,G}}
580
580
581
-
Return the `Interlayer` corresponding to `interlayer` where `layer_1` and `layer_2` are swapped. Its name will be `symmetric_interlayer_name` (defaults to `interlayer_(interlayer.layer_2)_(interlayer.layer_1)`).
581
+
Return the `Interlayer` corresponding to `interlayer` where `layer_1` and `layer_2` are swapped. Its name will be `symmetric_interlayer_name` (defaults to `interlayer_(interlayer.layer_2)_(interlayer.layer_1)`).
0 commit comments