Set the weight of one or more edges in a network


set_weight_from(network, agent-id, pair-expression)
set_weight_from(network, agent-list, pair-expression)


Set the weight on the edge to the calling agent from the agent-id in the given network. Has no effect if there is not already an edge between the two agents in the network.

If the second argument is a list of agent IDs, all existing edges to the calling agent from the agents in the list are set.

The pair-expression is evaluated for each target agent to set the weight of the edge, if it exists. All agent properties in the pair-expression refer to the calling agent, but any occurrence of the special variable “_” refers to the target agent.



The name of a network. The network must bedeclared in the model.


An expression that evaluates to an agent ID.


A list-expression that evaluates to a list of agent IDs.


A pair-expression that evaluates to a number.


Set the weights in the age-network on edges from members of the agent’s household, with weight equal to the age of the other agent minus the age of the calling agent:

set_weight_from(age_network, members(Household), ask(_,age) - age)

See Also

set_weight_to(), pair-expression