Reputation: 177
I have a set j and parameter edge. I have a graph too.
Set j/1*5/;
Alias(j,jp);
Parameter edge(j,jp)
That edge(j,jp) =1 if there is arc from j to jp , and it's 0 if there isn't arc from j to jp. I maked edge(j,jp) .
I want to define a set or parameter , for saving index of neighborhood of node "j".
I Mean , neighborhood (j)={jp : edge(j,jp)=1}
I write ,below command but I get error.
Set neighborhood (j)
Neighborhood (j)$edge (j,jp) =JP.val;
How can I obtain neighborhood of especial node?
Upvotes: 0
Views: 50
Reputation: 2292
Do you work with an directed graph and assume there is just one neighbor for each j? Then, try this:
Set j/1*3/;
Alias(j,jp);
Parameter edge(j,jp) / 1.2 1, 2.3 1, 3.1 1 /;
Parameter Neighborhood (j);
Neighborhood (j) = sum(jp$edge(j,jp), jp.val);
Otherwise: What do you expect to see in Neighborhood, if there is more than one neighbor?
Upvotes: 1