An Edge
object represents a connection between two agents in a network. Edges are stored in the Edges
container in Agent.edges
. Models with one network can use these methods without specifying a kind
parameter, in which case kind
defaults to 'edge'
. kind
can also be specified explicitly in order to use multiple networks in the same model.
This class should not generally be instantiated directly. Use agent.edges.add()
instead to create an Edge
object in order to ensure that the new edge is accessible to each agent.
Initialization Parameters
agent1 — Agent, required
The first vertex of the edge.
agent2 — Agent, required
The second vertex of the edge.
kind — str, optional
The kind of edge to create. Used for creating multiple networks. The function can be used without specifying a
kind
, in which case one network of kind'edge'
will be used.Default value: 'edge'
direction — int|bool|Agent, optional
- If an
int
,direction>0
signifies an outbound edge from the agent,direction<0
creates in inbound edge to the agent, anddirection==0
creates an undirected edge. - If a
bool
,True
creates an outbound link from the agent andFalse
creates an undirected link. - If an agent object, indicates which agent should be the endpoint, the other being the startpoint.
- If
None
, creates an undirected edge.
Default value: None
- If an
weight — num, optional
The weight of the connection.
Default value: 1
Methods
Click a method name for more detailed documentation.
cut( )
Breaks the connection between the two agents represented by the edge and removes the
Edge
object from theedges
property of both agents. This function takes no arguments.partner( agent )
When passed an agent object, returns the other agent.
reassign( oldagent, newagent )
Moves a vertex from
oldagent
tonewagent
.
Object Properties
active — bool
Whether the edge is currently connecting its two vertices. See
Edge.cut()
.Initial value: True
vertices — tuple(Agent, Agent)
The two agents being connected by the edge.
weight — num
The weight of the connection between the two agents.
Initial value: 1
directed — bool
Whether the edge proceeds in one direction or not.
Initial value: False
startpoint — Agent
If the edge is directed, the startpoint of the edge.
None
if the edge is undirected.Initial value: None
endpoint — Agent
If the edge is directed, the endpoint of the edge.
None
if the edge is undirected.Initial value: None
kind — str
The kind of connection. Different values indicate different networks.
Hooks
Click a hook name for more detailed documentation.
edgeReassign( edge, oldagent, newagent )
Runs when an edge is reassigned from one agent to another.
edgeCut( edge )
Runs when a connection between two agents is cut.
edgeInit( edge, kind, agent1, … )
Runs at the initialization of a new connection between two agents. Can be used to assign new properties to
Edge
objects.
Notes and Examples