Note

This page is a reference documentation. It only explains the function signature, and not how to use it. Please refer to the user guide for the big picture.

meierlab.networks.graph.get_within_network_connectivity#

meierlab.networks.graph.get_within_network_connectivity(subgraph, edge_attr='weight')[source]#

Calculate the average weight of edges in a subgraph.

This provides the effective ‘within-network’ connectivity.

Parameters:
subgraphnetworkx.Graph.subgraph

A subgraph with edge attributes: edge_attr to average.

edge_attrstr, optional

Edge attribute label, by default “weight”.

Returns:
numpy.float64

Average of weighted edges in subgraph.

Examples

>>> from meierlab.networks import graph
>>> atlas = 'schaefer2018/atlas.csv'
>>> sub_file = 'sub-001.tsv'
>>> G = graph.gen_base_graph_from_atlas(atlas)
>>> g = graph.gen_graph_from_matrix(G,atlas,sub_file)
>>> rsn_list = graph.gen_subnetwork_list(g)
>>> subgraphs = graph.gen_subnetwork_subgraphs(g, rsn_list)
>>> avg = graph.get_within_network_connectivity(subgraphs[0])
>>> avg
0.39999999999999997