edge_average

Contents

edge_average#

graph_tool.stats.edge_average(g, eprop)[git][source]#

Return the average of the given edge property.

Parameters:
gGraph

Graph to be used.

epropEdgePropertyMap

Edge property to be used for the average.

Returns:
averagefloat or numpy.ndarray

The average of the given property. For vector-valued properties, this is an array with the average of each component.

stdfloat or numpy.ndarray

The standard deviation of the average. If the graph has no edges, both values are nan (for vector-valued properties, empty arrays).

See also

vertex_hist

Vertex histograms.

edge_hist

Edge histograms.

vertex_average

Average of vertex degree, properties.

distance_histogram

Shortest-distance histogram.

Notes

The algorithm runs in \(O(|E|)\) time.

Parallel implementation.

If enabled during compilation, this algorithm will run in parallel using OpenMP. See the parallel algorithms section for information about how to control several aspects of parallelization.

Examples

>>> from numpy import arange
>>> from numpy.random import random
>>> g = gt.random_graph(1000, lambda: (5, 5))
>>> eprop = g.new_edge_property("double")
>>> eprop.get_array()[:] = random(g.num_edges())
>>> print(gt.edge_average(g, eprop))
(0.49683199099042286, 0.0040956287508060...)