@@ -185,8 +185,45 @@ function getindex(g::MetaGraph, label)
185
185
end
186
186
getindex (g:: MetaGraph , label_1, label_2) = g. eprops[arrange (g, label_1, label_2)]
187
187
188
+ """
189
+ haskey(g, :label)
190
+
191
+ Determine whether a graph `g` contains the vertex `:label`.
192
+
193
+ ```jldoctest; setup = :(using MetaGraphsNext; using LightGraphs: Graph)
194
+ julia> colors = MetaGraph(Graph(), VertexMeta = String, EdgeMeta = Symbol, gprops = "special");
195
+
196
+ julia> colors[:red] = "warm";
197
+
198
+ julia> haskey(colors, :red)
199
+ true
200
+
201
+ julia> haskey(colors, :blue)
202
+ false
203
+ ```
204
+ """
188
205
haskey (g:: MetaGraph , label) = haskey (g. vprops, label)
189
- haskey (g:: MetaGraph , label_1, label_2) = haskey (g. eprops, arrange (g, label_1, label_2))
206
+
207
+ """
208
+ haskey(g, :v1, :v2)
209
+
210
+ Determine whether a graph `g` contains an edge from `:v1` to `:v2`. The order of `:v1` and `:v2`
211
+ only matters if `g` is a digraph.
212
+
213
+ ```jldoctest; setup = :(using MetaGraphsNext; using LightGraphs: Graph)
214
+ julia> colors = MetaGraph(Graph(), VertexMeta = String, EdgeMeta = Symbol, gprops = "special");
215
+
216
+ julia> colors[:red] = "warm"; colors[:blue] = "cool"; colors[:red, :blue] = :purple
217
+ :purple
218
+
219
+ julia> haskey(colors, :red, :blue) && haskey(colors, :blue, :red)
220
+ true
221
+
222
+ julia> haskey(colors, :red, :yellow)
223
+ false
224
+ ```
225
+ """
226
+ haskey (g:: MetaGraph , label_1, label_2) = haskey (g, label_1) && haskey (g, label_2) && haskey (g. eprops, arrange (g, label_1, label_2))
190
227
191
228
function setindex! (g:: MetaGraph , val, label)
192
229
vprops = g. vprops
0 commit comments