RandomNet#
- class RandomNet(pars=None, key_dict=None, **kwargs)[source]#
Bases:
DynamicNetworkRandom connectivity between agents
Attributes
betaRelative transmission on each network edge
membersReturn sorted array of all members
nowShortcut to self.t.now()
p1The first half of a network edge (person 1)
p2The second half of a network edge (person 2)
statesReturn a flat list of all states
statesdictReturn a flat dictionary (objdict) of all states
tiGet the current module timestep
timevecShortcut to self.t.timevec
Methods
- get_edges(inds, n_contacts)[source]#
Efficiently find edges
Note that because of the shuffling operation, each person is assigned 2N contacts (i.e. if a person has 5 contacts, they appear 5 times in the ‘source’ array and 5 times in the ‘target’ array). Therefore, the number_of_contacts argument to this function should be HALF of the total contacts a person is expected to have, if both the source and target array outputs are used (e.g. for social contacts)
adjusted_number_of_contacts = np.round(number_of_contacts / 2).astype(ss.dtype.int)
Whereas for asymmetric contacts (e.g. staff-public interactions) it might not be necessary
- Parameters:
inds – List/array of person indices
number_of_contacts – List/array the same length as inds with the number of unidirectional
Therefore (contacts to assign to each person.)
number (a person will have on average TWICE this)
contacts. (of random)
Returns: Two arrays, for source and target