@@ -33,7 +33,7 @@ Graphs.has_vertex(subgraph::S, v::T) where {T,S<:AbstractSubGraph{T}} = has_ver
3333
3434Return the number of vertices in `subgraph`.
3535"""
36- Graphs. nv (subgraph:: AbstractSubGraph ) = nv (subgraph. graph) # length(vertices(subgraph))
36+ Graphs. nv (subgraph:: AbstractSubGraph ) = nv (subgraph. graph)
3737
3838"""
3939 vertices(subgraph::AbstractSubGraph)
@@ -121,9 +121,11 @@ mv_neighbors(subgraph::AbstractSubGraph, mv::MultilayerVertex) = mv_outneighbors
121121Return `v` associated with `V`.
122122"""
123123function get_v (subgraph:: AbstractSubGraph , V:: MultilayerVertex )
124+ # Convert V to a bare vertex
124125 bare_V = get_bare_mv (V)
126+ # Check if subgraph has this vertex
125127 has_vertex (subgraph, bare_V) || return nothing
126-
128+ # Get the list of edges
127129 subgraph. v_V_associations (bare_V)
128130end
129131
@@ -134,10 +136,11 @@ end
134136Return the `MultilayerVertex` whose internal representation is `v`.
135137"""
136138function get_V (subgraph:: S , v:: T ; perform_checks:: Bool = false ) where {T,U, S <: AbstractSubGraph{T,U} }
139+ # Check if v is a vertex label in subgraph
137140 if perform_checks
138141 haskey (subgraph. v_V_associations,v) || throw (ErrorException (" $v is not an integer label of any vertex in the subgraph" ))
139142 end
140-
143+ # Return the vertex object
141144 return subgraph. v_V_associations[v]
142145end
143146
@@ -150,11 +153,13 @@ end
150153Return `V` together with its metadata.
151154"""
152155function get_rich_mv (subgraph:: S , i:: T ; perform_checks:: Bool = false ) where {T,U, S <: AbstractSubGraph{T,U} }
156+ # Make sure that i is a valid vertex in the subgraph
153157 if perform_checks
154158 haskey (subgraph. v_V_associations,i) || throw (ErrorException (" $i is not an integer label of any vertex in the subgraph" ))
155159 end
156-
160+ # Get the bare vertex corresponding to i
157161 bare_V = subgraph. v_V_associations[i]
162+ # Return the vertex as a multilayer vertex
158163 return MV (bare_V. node, bare_V. layer, get_metadata (subgraph, bare_V))
159164end
160165
171176"""
172177 get_metadata(subgraph::AbstractSubGraph, bare_mv::MultilayerVertex)
173178
174- Return the metadata of the vertex `bare_mv` in `subgraph` (metadata assigend to `bare_mv` will be discarded).
179+ Return the metadata of the vertex `bare_mv` in `subgraph` (metadata assigned to `bare_mv` will be discarded).
175180"""
176181get_metadata (subgraph:: AbstractSubGraph , bare_mv:: MultilayerVertex ) = _get_vertex_metadata (subgraph. graph, get_v (subgraph, bare_mv))
177182
@@ -211,14 +216,12 @@ Return the number of edges in `subgraph`.
211216"""
212217Graphs. ne (subgraph:: AbstractSubGraph ) = ne (subgraph. graph)
213218
214-
215-
216219"""
217220 edges(subgraph::S) where {T,U,S<:AbstractSubGraph{T,U}}
218221
219222Return an iterator over all the edges of `subgraph`.
220223"""
221- function Graphs. edges (subgraph:: S ) where {T,U,S<: AbstractSubGraph{T,U} } # = subgraph.edge_list
224+ function Graphs. edges (subgraph:: S ) where {T,U,S<: AbstractSubGraph{T,U} }
222225 (
223226 MultilayerEdge (
224227 get_rich_mv (subgraph, src),
@@ -344,11 +347,14 @@ SimpleWeightedGraphs.weights(subgraph::S) where {T,U,S<:AbstractSubGraph{T,U}} =
344347Overload equality for `AbstractSubGraph`s.
345348"""
346349function Base.:(== )(x:: AbstractSubGraph , y:: AbstractSubGraph )
350+ # Check that each field in AbstractSubGraph is equal in x and y
347351 for field in fieldnames (AbstractSubGraph)
352+ # If the field is not equal in x and y, return false
348353 if @eval $ x.$ field != $ y.$ field
349354 return false
350355 end
351356 end
357+ # If all fields are equal in x and y, return true
352358 return true
353359end
354360
0 commit comments