@@ -271,28 +271,36 @@ def graph_summary(G):
271
271
return dict ( lp = lp .mean (), clust = clust .mean (), glob_eff = glob_eff .mean (),
272
272
loc_eff = loc_eff .mean () )
273
273
274
+
274
275
def nodal_summaryOut (G , n_nodes ):
275
- """ Compute statistics for individual nodes
276
+ """Compute statistics for individual nodes.
276
277
277
278
Parameters
278
279
----------
279
- G: graph data output from mkgraph
280
- out: array output from nodal_summaryOut, so can keep appending
281
- cost: cost value for these calculations
282
- n_nodes: number of nodes in graph.
280
+ G: networkx graph
281
+ An undirected graph.
282
+
283
+ n_nodes: integer
284
+ Number of nodes in G.
283
285
284
286
Returns
285
287
-------
288
+ dictionary
289
+ The keys of this dictionary are lp (which refers to path
290
+ length), clust (clustering coefficient), b_cen (betweenness
291
+ centrality), c_cen (closeness centrality), nod_eff (nodal
292
+ efficiency), loc_eff (local efficiency), and deg (degree). The
293
+ values are lists of metrics, in ascending order of node labels.
286
294
287
- A dict with: lp, clust, b_cen, c_cen, nod_eff, loc_eff, degree."""
288
-
289
- lp = nodal_pathlengths (G ,n_nodes ) #can't use the regular one, because it substitutes [] for disconnected nodes
295
+ """
296
+ # nodal_pathlengths is needed because NetworkX's shortest_path_length
297
+ # returns an empty list for disconnected nodes.
298
+ lp = nodal_pathlengths (G ,n_nodes )
290
299
clust = np .array (nx .clustering (G ).values ())
291
300
b_cen = np .array (nx .betweenness_centrality (G ).values ())
292
301
c_cen = np .array (nx .closeness_centrality (G ).values ())
293
- nod_eff = nodal_efficiency (G )
294
- loc_eff = local_efficiency (G )
302
+ nod_eff = nodal_efficiency (G )
303
+ loc_eff = local_efficiency (G )
295
304
deg = G .degree ().values ()
296
-
297
305
return dict (lp = lp , clust = clust , b_cen = b_cen , c_cen = c_cen , nod_eff = nod_eff ,
298
- loc_eff = loc_eff ,deg = deg )
306
+ loc_eff = loc_eff , deg = deg )
0 commit comments