I'm trying to model a constraint in Python using Pulp and networkX that is getting the sum of the edges that contain this node over all the nodes. The constraint can be like that: $$\sum_{m\in\cal N}z_{(m,n)}\succeq k(1-y_m),\quad\forall m\in\cal N.$$
I have used this code to model the constraint:
for m in g.nodes(): prob += pulp.lpSum(z[(m,n)] for m in g.nodes()) >= k*(1-y[m])
This piece of code rises an error about the key of the dictionary since the variable dictionary $z$ doesn't contains all the neighbors values. If I used this instead
for m in g.nodes(): prob += pulp.lpSum(z[(m,n)] for (u,v) in g.edges()) >= k*(1-y[m])
It sums all the links, not the ones associated with link $m$.
I would like your help with this!.
Please be noted that $z_{(m,n)}$ is a dict of the graph edges