widest_path

Contents

widest_path#

graph_tool.structure.widest_path(g, source, target, weights)[git][source]#

Return a widest path from a source to a target vertex.

Parameters:
gGraph

Graph to be used.

sourceVertex or int

Source vertex.

targetVertex or int

Target vertex.

weightsEdgePropertyMap

Edge weights (capacities).

Returns:
vertex_listlist of Vertex

The vertices of the path, empty if the target cannot be reached.

edge_listlist of Edge

The edges of the path (for parallel edges, one of largest weight).

widthfloat

The smallest edge weight along the path.

See also

widest_distance

Widths of the widest paths to all vertices

shortest_path

Shortest path

Notes

A widest path from \(s\) to \(t\) is a path \(P\) (a directed one, for directed graphs) that maximizes its width \(\min_{e\in P} w_e\), the smallest weight of its edges. The path is obtained from the tree of widest_distance(), in time \(O((V + E)\log V)\).

Examples

>>> g = gt.Graph([(0, 1), (1, 2), (0, 2)], directed=False)
>>> w = g.new_ep("double", vals=[5, 4, 2])
>>> vs, es, width = gt.widest_path(g, 0, 2, w)
>>> print([int(v) for v in vs], width)
[0, 1, 2] 4.0