Reference 〉Class

Edge( Agent agent1, Agent agent2, str kind = 'edge', int|bool|Agent direction = None, num weight = 1 )

Helipad allows the creation of networks among agents with the Edge class. Edges are stored 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.newEdge() 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, and direction==0 creates an undirected edge.
    • If a bool, True creates an outbound link from the agent and False 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

  • weight num, optional

    The weight of the connection.

    Default value: 1

Methods

Click a method name for more detailed documentation.

  • reassign( oldagent, newagent )

    Moves a vertex from oldagent to newagent.

  • partner( agent )

    When passed an agent object, returns the other agent.

  • cut( )

    Breaks the connection between the two agents represented by the edge and removes the Edge object from the edges property of both agents. This function takes no arguments.

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

  1. Contribute a Note

    Your email address will not be published. Required fields are marked *

    You may use limited HTML for formatting. Please embed blocks of code in <pre><code> </code></pre> tags.