widest_distance

widest_distance#

graph_tool.structure.widest_distance(g, source, weights, pred_map=False)[git][source]#

Return the width of the widest paths from a source vertex to all others.

Parameters:
gGraph

Graph to be used.

sourceVertex or int

Source vertex.

weightsEdgePropertyMap

Edge weights (capacities).

pred_mapbool (optional, default: False)

If True, a predecessor map of a tree of widest paths is also returned.

Returns:
widthVertexPropertyMap

The largest bottleneck (smallest edge weight along the path) of a path from the source to every vertex, which is \(+\infty\) for the source and \(-\infty\) for unreachable vertices.

predVertexPropertyMap

Predecessor of every vertex in a tree of widest paths (the vertex itself for the source and unreachable vertices). Only returned if pred_map == True.

See also

widest_path

A single widest path

shortest_distance

Shortest distances

Notes

The width (or bottleneck) of a path \(P\) is the smallest weight of its edges, and the value returned for vertex \(v\) is

\[b(v) = \max_{P:\,s\to v}\;\min_{e\in P} w_e,\]

where the maximum runs over the paths from the source \(s\) to \(v\) (directed paths, for directed graphs), with \(b(s) = +\infty\) and \(b(v) = -\infty\) if \(v\) cannot be reached. The widest (or maximum bottleneck, or maximum capacity) paths are found with the variant of Dijkstra’s algorithm that maximizes the smallest edge weight instead of minimizing the sum [pollack-maximum-1960], in time \(O((V + E)\log V)\).

References

[pollack-maximum-1960]

Maurice Pollack, “The maximum capacity through a network”, Operations Research 8, 733-736 (1960), DOI: 10.1287/opre.8.5.733 [sci-hub, @tor]

Examples

>>> g = gt.Graph([(0, 1), (1, 2), (0, 2)], directed=False)
>>> w = g.new_ep("double", vals=[5, 4, 2])
>>> print(gt.widest_distance(g, 0, w).a)
[inf  5.  4.]