Represents a node in a network. Each node has a unique index, its position in the network’s list of nodes.
Node(tpm, cm, index, state, node_labels)¶
A node in a subsystem.
- tpm (np.ndarray) – The TPM of the subsystem.
- cm (np.ndarray) – The CM of the subsystem.
- index (int) – The node’s index in the network.
- state (int) – The state of this node.
- node_labels (
NodeLabels) – Labels for these nodes.
np.ndarray – The node TPM is an array with shape
(2,)*(n + 1), where
nis the size of the
Network. The first
ndimensions correspond to each node in the system. Dimensions corresponding to nodes that provide input to this node are of size 2, while those that do not correspond to inputs are of size 1, so that the TPM has \(2^m \times 2\) elements where \(m\) is the number of inputs. The last dimension corresponds to the state of the node in the next timestep, so that
node.tpm[..., 0]gives probabilities that the node will be ‘OFF’ and
node.tpm[..., 1]gives probabilities that the node will be ‘ON’.
The TPM of this node containing only the ‘OFF’ probabilities.
The TPM of this node containing only the ‘ON’ probabilities.
The set of nodes with connections to this node.
The set of nodes this node has connections to.
The textual label for this node.
Return whether this node equals the other object.
Two nodes are equal if they belong to the same subsystem and have the same index (their TPMs must be the same in that case, so this method doesn’t need to check TPM equality).
Labels are for display only, so two equal nodes may have different labels.
Return a JSON-serializable representation.
generate_nodes(tpm, cm, network_state, indices, node_labels=None)¶
Nodeobjects for a subsystem.
- tpm (np.ndarray) – The system’s TPM
- cm (np.ndarray) – The corresponding CM.
- network_state (tuple) – The state of the network.
- indices (tuple[int]) – Indices to generate nodes for.
NodeLabels) – Textual labels for each node.
The nodes of the system.
Broadcast a node TPM over the full network.
This is different from broadcasting the TPM of a full system since the last dimension (containing the state of the node) contains only the probability of this node being on, rather than the probabilities for each node.