find_neighbor_sites#

find_neighbor_sites(sites, **kwargs)[source]#

Finds all nodes that are directly connected to the input nodes

Parameters:
  • network (dict) – The network dictionary

  • inds (array_like) – A list of node indices whose neighbors are sought

  • flatten (bool) – If True (default) the returned result is a compressed array of all neighbors, or a list of lists with each sub-list containing the neighbors for each input site. Note that an unflattened list might be slow to generate since it is a Python list rather than a Numpy array.

  • include_input (bool) – If False (default) the input nodes will be removed from the result.

  • logic (str) –

    Specifies logic to filter the resulting list. Options are:

    logic

    Description

    ’or’

    (default) All neighbors of the inputs. This is also known as the ‘union’ in set theory or ‘any’ in boolean logic. Both keywords are accepted and treated as ‘or’.

    ’xor’

    Only neighbors of one and only one inputs. This is useful for finding neighbors that are not shared by any of the input nodes. ‘exclusive_or’ is also accepted.

    ’xnor’

    Neighbors that are shared by two or more inputs . This is equivalent to finding all neighbors with ‘or’, minus those found with ‘xor’, and is useful for finding neighbors that the inputs have in common. ‘nxor’ is also accepted.

    ’and’

    Only neighbors shared by all inputs. This is also known as ‘intersection’ in set theory and (somtimes) as ‘all’ in boolean logic. Both keywords are accepted and treated as ‘and’.

Returns:

nodes – An array containing the neighboring nodes filtered by the given logic. If flatten is False then the result is a list of lists containing the neighbors of each input site.

Return type:

ndarray

Notes

The logic options are applied to neighboring nodes only, thus it is not possible to obtain nodes that are part of the global set but not neighbors. This is because the list of global nodes might be very large.