explicit_edges#
- class brainpy.state.network.explicit_edges(pre_idx, post_idx)[source]#
Return a rule wiring exactly the given
(pre_idx[i], post_idx[i])edges.A connection rule built from a precomputed edge list, for topologies that are easier to enumerate directly than to express through a sampling rule (e.g. the structured inhibitory graph of a constraint-satisfaction network). The edges are handed to the same projection paths used by the sampling rules, so a single call realizes the whole topology as one projection – avoiding the per-edge / per-group projection explosion (and the per-
cont()retrace) of many smallconnect()calls.- Parameters:
pre_idx (
array_likeofint) – Equal-length 1-D arrays of segment-local source/target neuron indices, in the coordinate frame of the populations passed toconnect(). Edgeiconnectspre_idx[i] -> post_idx[i]. Order is preserved and duplicates are kept – the caller controls multapses.post_idx (
array_likeofint) – Equal-length 1-D arrays of segment-local source/target neuron indices, in the coordinate frame of the populations passed toconnect(). Edgeiconnectspre_idx[i] -> post_idx[i]. Order is preserved and duplicates are kept – the caller controls multapses.
- Returns:
A connection rule returning the precomputed edge set verbatim (the sampling
key/ autapse / multapse flags are ignored).- Return type:
_ExplicitEdges- Raises:
ValueError – If
pre_idx/post_idxare not 1-D, differ in length, or are not integer-typed.
See also
brainpy.state.all_to_all,brainpy.state.Simulator.connectExamples
>>> import numpy as np >>> import brainunit as u >>> from brainpy import state as bp >>> sim = bp.Simulator(dt=0.1 * u.ms) >>> pop = sim.create(bp.iaf_psc_exp, 5) >>> # wire 0->1, 0->4, 2->3 as one sparse projection >>> pre = np.array([0, 0, 2]) >>> post = np.array([1, 4, 3]) >>> _ = sim.connect(pop, pop, rule=bp.explicit_edges(pre, post), ... weight=-0.2 * u.pA, comm='sparse') >>> len(sim.get_connections(source=pop, target=pop)) 3