Skip to content

Commit 90416de

Browse files
2 parents ca1506e + 0b032ba commit 90416de

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

src/representations/abstracttensorrepresentation.jl

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
"""
22
AbstractTensorRepresentation{U}
33
4-
An abstrac type encoding a generic tensorial representation of the links and metadata of a multilayer graph.
4+
An abstract type encoding a generic tensorial representation of the links and metadata of a multilayer graph.
55
6-
Concrete subtypes must have an `array` field (a 4-dimaensional tensor of eltype U, indexes as [source_node_idx, destination_node_idx, source_layer_idx, destination_layer_idx ]), a .
6+
Concrete subtypes must have an `array` field (a 4-dimensional tensor of eltype U, indexes as [source_node_idx, destination_node_idx, source_layer_idx, destination_layer_idx ]).
77
88
# PARAMETRIC TYPES
99
10-
- `U`: the weight type of the multilayer graph;
10+
- `U`: the weight type of the multilayer graph.
1111
"""
1212
abstract type AbstractTensorRepresentation end
1313

@@ -16,25 +16,31 @@ abstract type AbstractTensorRepresentation end
1616
getindex(atr::AbstractTensorRepresentation, src_mv::MultilayerVertex, dst_mv::MultilayerVertex)
1717
"""
1818
function Base.getindex(atr::AbstractTensorRepresentation, src_mv::MultilayerVertex, dst_mv::MultilayerVertex)
19+
# Find the index of the source node in the array of node
1920
src_n_idx = atr.idx_N_associations(src_mv.node)
21+
# Find the index of the destination node in the array of node
2022
dst_n_idx = atr.idx_N_associations(dst_mv.node)
21-
23+
# Find the index of the source layer in the array of layers
2224
src_layer_idx = findfirst(name -> name == src_mv.layer, atr.layers_names)
25+
# Find the index of the destination layer in the array of layers
2326
dst_layer_idx = findfirst(name -> name == dst_mv.layer, atr.layers_names)
24-
27+
# Return the value in the array at the position of the source node, destination node, source layer, and destination layer
2528
return atr.array[src_n_idx, dst_n_idx, src_layer_idx, dst_layer_idx]
2629
end
2730

2831
"""
2932
getindex(atr::AbstractTensorRepresentation, src_tup::Tuple{String, Symbol}, dst_tup::Tuple{String, Symbol})
3033
"""
3134
function Base.getindex(atr::AbstractTensorRepresentation, src_tup::Tuple{String, Symbol}, dst_tup::Tuple{String, Symbol})
35+
# Find the index of the source node in the adjacency tensor
3236
src_n_idx = atr.idx_N_associations(Node(src_tup[1]))
37+
# Find the index of the destination node in the adjacency tensor
3338
dst_n_idx = atr.idx_N_associations(Node(dst_tup[1]))
34-
39+
# Find the index of the source layer in the adjacency tensor
3540
src_layer_idx = findfirst(name -> name == src_tup[2], atr.layers_names)
41+
# Find the index of the destination layer in the adjacency tensor
3642
dst_layer_idx = findfirst(name -> name == dst_tup[2], atr.layers_names)
37-
43+
# Return the value of the adjacency tensor at the given indices
3844
return atr.array[src_n_idx, dst_n_idx, src_layer_idx, dst_layer_idx]
3945
end
4046

src/traits.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ Check whether `g` is weighted.
2222
"""
2323
is_weighted(g::G) where {G<:Type{<:AbstractGraph}} = istrait(IsWeighted{g})
2424

25-
26-
2725
"""
2826
IsMeta{X}
2927

src/utilities.jl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ function check_unique(vec::Union{Missing,<:Vector,<:Tuple})
3434
return ismissing(vec) ? true : length(setdiff(unique(vec), vec)) == 0
3535
end
3636

37-
38-
39-
40-
4137
"""
4238
multilayer_kronecker_delta(dims...)
4339

0 commit comments

Comments
 (0)