# BooleanNetwork¶

class neet.boolean.BooleanNetwork(size, names=None, metadata=None)[source]

The BooleanNetwork class is a base class for all of Neet’s Boolean networks. The BooleanNetwork class inherits from both neet.UniformNetwork and neet.boolean.SensitivityMixin, and specializes the inherited neet.StateSpace methods to exploit the Boolean structure.

In addition to all of its inherited methods, BooleanNetwork also exposes the following methods:

 subspace Generate all states in a given subspace. distance Compute the Hamming distance between two states. hamming_neighbors Get all states that one unit of Hamming distance from a given state.

BooleanNetwork is an abstract class, meaning it cannot be instantiated. Initialization of a BooleaNetwork requires, at a minimum, the number of nodes in the network. As with all classes that derive from neet.Network, the user may optionally provide a list of names for the nodes of the network and a metadata dictionary for the network as a whole (e.g. citation information).

Parameters: size (int) – number of nodes in the network names (seq) – an iterable object of the names of the nodes in the network metadata (dict) – metadata dictionary for the network
subspace(indices, state=None)[source]

Generate all states in a given subspace. This method varies each node specified by the indicies array independently. The optional state parameter specifies the state of the non-varying states of the network. If state is not provided, all nodes not in indicies will have state 0.

Examples

>>> s_pombe.subspace([0])
<generator object BooleanNetwork.subspace at 0x...>
>>> list(s_pombe.subspace([0]))
[[0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0]]
>>> list(s_pombe.subspace([0, 3]))
[[0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0, 0], [1, 0, 0, 1, 0, 0, 0, 0, 0]]

>>> s_pombe.subspace([0], state=[0, 1, 0, 1, 0, 1, 0, 1, 0])
<generator object BooleanNetwork.subspace at 0x...>
>>> list(s_pombe.subspace([0], state=[0, 1, 0, 1, 0, 1, 0, 1, 0]))
[[0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 1, 0, 1, 0, 1, 0, 1, 0]]
>>> list(s_pombe.subspace([0, 3], state=[0, 1, 0, 1, 0, 1, 0, 1, 0]))
[[0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 0, 0, 1, 0, 1, 0], [1, 1, 0, 0, 0, 1, 0, 1, 0]]

Parameters: indicies (list, numpy.ndarray, iterable) – the indicies to vary in the subspace state (list, numpy.ndarray) – a state which specifes the state of the non-varying nodes the states of the subspace
distance(a, b)[source]

Compute the Hamming distance between two states.

Examples

>>> s_pombe.distance([0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 1, 0, 1, 0, 0])
4
>>> s_pombe.distance([0, 1, 0, 1, 1, 0, 1, 0, 0], [0, 1, 0, 1, 1, 0, 1, 0, 0])
0

Parameters: a (list, numpy.ndarray) – the first state b (list, numpy.ndarray) – the second state the Hamming distance between the states ValueError – if either state is not in the network’s state space
hamming_neighbors(state)[source]

Get all states that one unit of Hamming distance from a given state.

Examples

>>> s_pombe.hamming_neighbors([0, 0, 0, 0, 0, 0, 0, 0, 0])
[[1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1]]
>>> s_pombe.hamming_neighbors([0, 1, 1, 0, 1, 0, 1, 0, 0])
[[1, 1, 1, 0, 1, 0, 1, 0, 0], [0, 0, 1, 0, 1, 0, 1, 0, 0], [0, 1, 0, 0, 1, 0, 1, 0, 0], [0, 1, 1, 1, 1, 0, 1, 0, 0], [0, 1, 1, 0, 0, 0, 1, 0, 0], [0, 1, 1, 0, 1, 1, 1, 0, 0], [0, 1, 1, 0, 1, 0, 0, 0, 0], [0, 1, 1, 0, 1, 0, 1, 1, 0], [0, 1, 1, 0, 1, 0, 1, 0, 1]]

Parameters: state (list, numpy.ndarray) – the state whose neighbors are desired a list of neighbors of the given state ValueError – if the state is not in the network’s state space