graph_tool.stats.vertex_average#

graph_tool.stats.vertex_average(g, deg)[source]#

Return the average of the given degree or vertex property.

Parameters:
gGraph

Graph to be used.

degstring or VertexPropertyMap

Degree or property to be used for the histogram. It can be either “in”, “out” or “total”, for in-, out-, or total degree of the vertices. It can also be a vertex property map.

Returns:
averagefloat

The average of the given degree or property.

stdfloat

The standard deviation of the average.

See also

vertex_hist

Vertex histograms.

edge_hist

Edge histograms.

edge_average

Average of edge properties.

distance_histogram

Shortest-distance histogram.

Notes

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

If enabled during compilation, this algorithm runs in parallel.

Examples

>>> from numpy.random import poisson
>>> g = gt.random_graph(1000, lambda: (poisson(5), poisson(5)))
>>> print(gt.vertex_average(g, "in"))
(5.028, 0.071240...)