disjoint_paths#
- graph_tool.flow.disjoint_paths(g, source, target, vertex_disjoint=True)[git][source]#
Return a maximum set of disjoint paths between two vertices.
- Parameters:
- Returns:
- paths
listofnumpy.ndarray List of paths, each given by the array of its vertices, from
sourcetotarget.
- paths
See also
vertex_connectivityVertex connectivity
edge_connectivityEdge connectivity
Notes
The paths are obtained from a maximum flow with unit capacities, as in
vertex_connectivity()andedge_connectivity(), whose number equals the local connectivity between the two vertices (if they are adjacent, the direct edge counts as one of the vertex-disjoint paths). The flow is decomposed into paths, and cycles of flow are discarded. The complexity is \(O(kE)\), where \(k\) is the number of paths.Examples
>>> g = gt.collection.data["football"] >>> paths = gt.disjoint_paths(g, g.vertex(0), g.vertex(10)) >>> print(len(paths)) 10
The paths can be highlighted in a drawing of the network:
>>> ecolor = g.new_ep("string", val="#999999") >>> ewidth = g.new_ep("double", val=0.5) >>> for p in paths: ... for u, v in zip(p[:-1], p[1:]): ... ecolor[g.edge(u, v)] = "#e41a1c" ... ewidth[g.edge(u, v)] = 3 >>> vcolor = g.new_vp("string", val="#cccccc") >>> vcolor[0] = vcolor[10] = "#9bbedc" >>> gt.graph_draw(g, g.vp.pos, vertex_fill_color=vcolor, edge_color=ecolor, ... edge_pen_width=ewidth, ... output="disjoint_paths-football.pdf") <...>
Maximum set of vertex-disjoint paths between two vertices of the network of American college football games. The endpoints are shown in blue, and the edges of the paths in red.#