edge_average#
- graph_tool.stats.edge_average(g, eprop)[git][source]#
Return the average of the given edge property.
- Parameters:
- g
Graph Graph to be used.
- eprop
EdgePropertyMap Edge property to be used for the average.
- g
- 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).
- averagefloat or
See also
vertex_histVertex histograms.
edge_histEdge histograms.
vertex_averageAverage of vertex degree, properties.
distance_histogramShortest-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...)