def inputASL(network,inputc):
"""
Returns the average shortest path length within the input-receiving subgraph.
Args:
network: networkx graph
inputc: MxN array, all nonzero positions are treated as 'input receiving'
"""
inputnodes = [tuple(ind) for ind in np.transpose(inputc.nonzero())]
lengths = [nx.shortest_path_length(network,src,trg) for src in inputnodes for trg in inputnodes]
return np.mean(lengths)
评论列表
文章目录