add_edge_to()

Adds an edge connecting the current agent to another agent or list of agents in a network.

Synopsis

add_edge_to(network, agent)

add_edge_to(network, agent-list)

Description

If an edge doesn’t exist in the given network from the current agent to a given agent, then the edge is created. Otherwise, the action has no effect. If the second argument is a list expression, then edges are created to each agent in the list.

For undirected networks, because direction does not matter, both add_edge_from() and add_edge_to() have the same effect of adding an undirected edge between the current and other agents.

Parameters

network

The name of the network to manipulate.

agent

An expression that evaluates to the ID of an agent.

agent-list

A list of agent ids.

Examples

If there is a directed network named NETWORK with three agents, agent1 and agent2, with agent ids id1 and id2 respectively, with no edge connections, then an edge from agent1 to agent2 can be created with the following action rule: .. code-block:: fred

if (id == id1) then add_edge_to(NETWORK, id2)

For additional examples, see the examples given for add_edge_from().

Note

If an expression does not evaluate to an agent ID, then this action has no effect.

See Also

delete_edge_from(), add_edge_to(), add_edge_from(), is_connected_to(), is_connected_from()