@@ -91,7 +91,7 @@ function edgevals_type(G::Type{<:AbstractValGraph}, key::Integer)
91
91
return fieldtype (edgevals_type (G), Int (key))
92
92
end
93
93
94
- function edgevals_type (G:: Type{<:AbstractValGraph{V, V_VALS, <: NamedTuple}} , key:: Symbol ) where {V, V_VALS}
94
+ function edgevals_type (G:: Type{<:AbstractValGraph} , key:: Symbol )
95
95
96
96
return fieldtype (edgevals_type (G), key)
97
97
end
@@ -117,17 +117,14 @@ Return true if `key` is an edge value key for this graph.
117
117
"""
118
118
hasedgekey (g:: AbstractValGraph , key) = hasedgekey (typeof (g), key)
119
119
120
- function hasedgekey (
121
- G:: Type{<:AbstractValGraph{V, V_VALS, E_VALS}} ,
122
- key:: Symbol ) where {V, V_VALS, E_VALS <: NamedTuple }
120
+ function hasedgekey (G:: Type{<:AbstractValGraph} , key:: Symbol )
123
121
124
- return key in E_VALS . names
122
+ return hasfield ( edgevals_type (G), key)
125
123
end
126
124
127
- function hasedgekey (
128
- G:: Type{<:AbstractValGraph{V, V_VALS, E_VALS}} ,
129
- key:: Integer ) where {V, V_VALS, E_VALS <: AbstractTuple }
125
+ function hasedgekey (G:: Type{<:AbstractValGraph} , key:: Integer )
130
126
127
+ E_VALS = edgevals_type (G)
131
128
return key in OneTo (length (E_VALS. types))
132
129
end
133
130
@@ -151,17 +148,14 @@ hasedgekey_or_throw(g::AbstractValGraph, key) = hasedgekey_or_throw(typeof(g), k
151
148
152
149
Return true if `key` is a vertex value key for this graph.
153
150
"""
154
- function hasvertexkey (
155
- G:: Type{<:AbstractValGraph{V, V_VALS}} ,
156
- key:: Symbol ) where {V, V_VALS <: NamedTuple }
151
+ function hasvertexkey (G:: Type{<:AbstractValGraph} , key:: Symbol )
157
152
158
- return key in V_VALS . names
153
+ return hasfield ( vertexvals_type (G), key)
159
154
end
160
155
161
- function hasvertexkey (
162
- G:: Type{<:AbstractValGraph{V, V_VALS}} ,
163
- key:: Integer ) where {V, V_VALS <: AbstractTuple }
156
+ function hasvertexkey (G:: Type{<:AbstractValGraph} , key:: Integer )
164
157
158
+ V_VALS = vertexvals_type (G)
165
159
return key in OneTo (length (V_VALS. types))
166
160
end
167
161
@@ -179,17 +173,14 @@ hasvertexkey_or_throw(g::AbstractValGraph, key) = hasvertexkey_or_throw(typeof(g
179
173
# hasgraphkey & hasgraphkey_or_throw
180
174
# ------------------------------------------------------
181
175
182
- function hasgraphkey (
183
- G:: Type{<:AbstractValGraph{V, V_VALS, E_VALS, G_VALS}} ,
184
- key:: Symbol ) where {V, V_VALS, E_VALS, G_VALS <: NamedTuple }
176
+ function hasgraphkey (G:: Type{<:AbstractValGraph} , key:: Symbol )
185
177
186
- return key ∈ G_VALS . names
178
+ return hasfield ( graphvals_type (G), key)
187
179
end
188
180
189
- function hasgraphkey (
190
- G:: Type{<:AbstractValGraph{V, V_VALS, E_VALS, G_VALS}} ,
191
- key:: Integer ) where {V, V_VALS, E_VALS, G_VALS <: AbstractTuple }
181
+ function hasgraphkey (G:: Type{<:AbstractValGraph} , key:: Integer )
192
182
183
+ G_VALS = graphvals_type (G)
193
184
return key ∈ OneTo (length (G_VALS. types))
194
185
end
195
186
@@ -665,10 +656,11 @@ ValEdgeIter(g, key) = ValEdgeIter{typeof(g)}(g, key)
665
656
666
657
Base. length (iter:: ValEdgeIter ) = count (_ -> true , iter)
667
658
668
- function Base. eltype (:: Type{<:ValEdgeIter{G, key}} ) where
669
- {V, V_VALS, E_VALS, G <: AbstractValGraph{V, V_VALS, E_VALS} , key}
659
+ function Base. eltype (:: Type{<:ValEdgeIter{G, key}} ) where {G, key}
670
660
671
661
E = is_directed (G) ? ValDiEdge : ValEdge
662
+ V = eltype (G)
663
+ E_VALS = edgevals_type (G)
672
664
673
665
if key == nothing
674
666
# TODO it might better to return an empty named tuple type in case
0 commit comments