neurokernel.routing_table.RoutingTable

class neurokernel.routing_table.RoutingTable(g=None)[source]

Routing table class.

Simple class that stores pairs of strings that can signify one-hop routes between entities in a graph. Assigning a value to a pair that isn’t in the class instance will result in the pair and value being added to the class instance. All data associated with a specific connection is stored as a dict; if a non-dict is assigned to a connection, it is stored in a dict with key ‘data’. Specific values in the dict can be retrieved by passing the desired key directly to the [] operator.

Examples

>>> r = RoutingTable()
>>> r['a', 'b'] = 1
>>> r['a', 'b']
1
>>> r['a', 'c'] = [1, 2]
>>> r['a', 'c']
[1, 2]
>>> r['a', 'c'] = {'x': 1}
>>> r['a', 'c', 'x']
1
>>> r['a', 'c']['x']
1
Parameters:g (networkx.DiGraph) – Directed graph that describes the routes between entities.
connections

list – List of directed connections between identifiers.

ids

list – Identifiers currently in routing table.

copy()

Return a copy of the routing table.

dest_ids(src_id)[source]

Destination identifiers connected to the specified source identifier.

has_node(n)[source]

Check whether the routing table contains the specified identifier.

ids()

IDs currently in routing

src_ids(dest_id)[source]

Source identifiers connected to the specified destination identifier.

subtable(ids)[source]

Return subtable containing only those connections between specified identifiers.

to_df()[source]

Return a pandas DataFrame listing all of the connections.

__init__(g=None)[source]

x.__init__(…) initializes x; see help(type(x)) for signature

Methods

__init__([g]) x.__init__(…) initializes x; see help(type(x)) for signature
copy()
dest_ids(src_id) Destination identifiers connected to the specified source identifier.
has_node(n) Check whether the routing table contains the specified identifier.
src_ids(dest_id) Source identifiers connected to the specified destination identifier.
subtable(ids) Return subtable containing only those connections between specified identifiers.
to_df() Return a pandas DataFrame listing all of the connections.

Attributes

connections List of directed connections between identifiers.
ids Identifiers currently in routing table.