I try to build a flow model using JuMP and (Meta)Graphs.jl. In particular I fail to index the variables. Here is an MWE:

using Graphs
using JuMP
g = SimpleDiGraph(4)
for i in 1:3
add_edge!(g, i, i+1)
end
model = Model()
T = 1:2
@variable(model, x[a in edges(g), t in T], Bin)
@constraint(model, x[Edge 1 => 2, 1] == 1) # error
@constraint(model, x[(2,3),1] == 1) # error

I tried several combinations, but always failed. As workaround, I could convert the edges as tuples, e.g.,

E = [(src(a), dst(a)) for a in edges(g)]
@variable(model, x[a in E, t in T], Bin)
@constraint(model, f[(2,3),1] == 1) # works

but canâ€™t I use the edges from g directly? Unfortunately, I did not find any examples in which JuMP is used together with objects from (Meta)Graphs.jl. Or is doing this a bad practice at all?