Imagine that you have a set of nodes (1 2 3) and that these nodes are connected through arcs (1,2), (1,3) and (2,3). Together representing a network.
How can I create a subset of nodes, containing all neighboring nodes? i.e. I wan't the following subset to be something like:
NeighborNode
1 2 3
2 1 3
3 1 2
This Python code is far off, but maybe you get the idea:
def NNode_rule(model,i):
for i in model.Nodes:
model.NNodes[i].add(model.ToNode[i]) if model.Nodes[i]==model.FromNode[i]
model.NNodes = Set(model.Nodes, initialize=NNode_rule)