edge_hist#
- graph_tool.stats.edge_hist(g, eprop, bins=[0, 1], float_count=True)[source]#
Return the edge histogram of the given property.
- Parameters:
- g
Graph
Graph to be used.
- eprop
EdgePropertyMap
Edge property to be used for the histogram.
- binslist of bins (optional, default: [0, 1])
List of bins to be used for the histogram. The values given represent the edges of the bins (i.e. lower and upper bounds). If the list contains two values, this will be used to automatically create an appropriate bin range, with a constant width given by the second value, and starting from the first value.
- float_countbool (optional, default: True)
If True, the counts in each histogram bin will be returned as floats. If False, they will be returned as integers.
- g
- Returns:
- counts
numpy.ndarray
The bin counts.
- bins
numpy.ndarray
The bin edges.
- counts
See also
vertex_hist
Vertex histograms.
vertex_average
Average of vertex properties, degrees.
edge_average
Average of edge 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_hist(g, eprop, linspace(0, 1, 11))) [array([525., 504., 502., 502., 467., 499., 531., 471., 520., 479.]), array([0. , 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1. ])]