khop_neighbourhood#
- khop_neighbourhood(domain, network_name=None, source_objects=None, k=1, include_source_in_neighbourhood=True)#
For a given network, find the k-hop neighbourhood of a set of source objects. If no source query is provided, the function will return the k-hop neighbourhood of all objects in the network. If no source objects are found in the network, a ValueError is raised.
- Parameters:
- domainobject
The domain containing the network.
- network_namestr, optional
The name of the network within the domain, by default None.
- source_objectsarray-like or query-like, optional
The source objects for which the k-hop neighbourhood is to be found, by default None.
- kint, optional
The number of hops to consider for the neighbourhood, by default 1.
- include_source_in_neighbourhoodbool, optional
Whether to include the source objects in the neighbourhood, by default True.
- Returns:
- dict
A dictionary where keys are source objects and values are arrays of objects in their k-hop neighbourhood.
- Raises:
- ValueError
If the network name is not provided or not found in the domain.
- ValueError
If the source query is not of the correct type.
- ValueError
If no source objects are found in the network.