connectivity

Functions for determining network connectivity properties.

pyphi.connectivity.apply_boundary_conditions_to_cm(external_indices, cm)

Remove connections to or from external nodes.

pyphi.connectivity.get_inputs_from_cm(index, cm)

Return indices of inputs to the node with the given index.

pyphi.connectivity.get_outputs_from_cm(index, cm)

Return indices of the outputs of node with the given index.

pyphi.connectivity.causally_significant_nodes(cm)

Return indices of nodes that have both inputs and outputs.

pyphi.connectivity.relevant_connections(n, _from, to)

Construct a connectivity matrix.

Parameters:
  • n (int) – The dimensions of the matrix
  • _from (tuple[int]) – Nodes with outgoing connections to to
  • to (tuple[int]) – Nodes with incoming connections from _from
Returns:

An \(N \times N\) connectivity matrix with the \((i,j)^{\textrm{th}}\) entry is 1 if \(i\) is in _from and \(j\) is in to, and 0 otherwise.

Return type:

np.ndarray

pyphi.connectivity.block_cm(cm)

Return whether cm can be arranged as a block connectivity matrix.

If so, the corresponding mechanism/purview is trivially reducible. Technically, only square matrices are “block diagonal”, but the notion of connectivity carries over.

We test for block connectivity by trying to grow a block of nodes such that:

  • ‘source’ nodes only input to nodes in the block
  • ‘sink’ nodes only receive inputs from source nodes in the block

For example, the following connectivity matrix represents connections from nodes1 = A, B, C to nodes2 = D, E, F, G (without loss of generality, note that nodes1 and nodes2 may share elements):

   D  E  F  G
A [1, 1, 0, 0]
B [1, 1, 0, 0]
C [0, 0, 1, 1]

Since nodes \(AB\) only connect to nodes \(DE\), and node \(C\) only connects to nodes \(FG\), the subgraph is reducible, because the cut

A,B    C
─── ✕ ───
D,E   F,G

does not change the structure of the graph.

pyphi.connectivity.block_reducible(cm, nodes1, nodes2)

Return whether connections from nodes1 to nodes2 are reducible.

Parameters:
  • cm (np.ndarray) – The network’s connectivity matrix.
  • nodes1 (tuple[int]) – Source nodes
  • nodes2 (tuple[int]) – Sink nodes
pyphi.connectivity.is_strong(cm, nodes=None)

Return whether the connectivity matrix is strongly connected.

Parameters:cm (np.ndarray) – A square connectivity matrix.
Keyword Arguments:
 nodes (tuple[int]) – A subset of nodes to consider.
pyphi.connectivity.is_weak(cm, nodes=None)

Return whether the connectivity matrix is weakly connected.

Parameters:cm (np.ndarray) – A square connectivity matrix.
Keyword Arguments:
 nodes (tuple[int]) – A subset of nodes to consider.
pyphi.connectivity.is_full(cm, nodes1, nodes2)

Test connectivity of one set of nodes to another.

Parameters:
  • cm (np.ndarrray) – The connectivity matrix
  • nodes1 (tuple[int]) – The nodes whose outputs to nodes2 will be tested.
  • nodes2 (tuple[int]) – The nodes whose inputs from nodes1 will be tested.
Returns:

True if all elements in nodes1 output to some element in nodes2 and all elements in nodes2 have an input from some element in nodes1, or if either set of nodes is empty; False otherwise.

Return type:

bool