Reference 〉 Function

Agents.createNetwork(densityfloat, kindstr'edge', primstrNone)

Creates a random undirected and unweighted network of a certain density among agents.

This function can only be called once agents are created, so it will generally be called in the modelPostSetup hook.

Parameters

  • density float, required

    A number between 0 and 1 indicating the desired graph density, i.e. the probability that any two agents will be directly connected.

  • kind str, optional

    A string indicating the edge kind, in order to allow for multiple networks.

    Default value: 'edge'

  • prim str, optional

    The agent primitive among which to create the network. If prim==None the network will be created among agents of all primitives.

    Default value: None

Return Value networkx.Graph

A NetworkX Graph object representing the created network.

Notes and Examples

  1. charwick

    Jun 04, 2020 at 22:25

    To create a network at the beginning of the model, use the modelPostSetup hook, as it runs right after agents are created.

    @heli.hook
    def modelPostSetup(model):
    	n = model.agents.createNetwork(0.2)
  2. 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.

History