all_minimal_separators#
- graph_tool.flow.all_minimal_separators(g, source=None, target=None, max_n=0)[git][source]#
Return all minimal vertex separators of the graph, or between two vertices.
- Parameters:
- g
Graph Graph to be used. If it is directed, it is treated as undirected.
- source
Vertex(optional, default:None) Source vertex. If given,
targetmust be given as well, and only the minimal separators between them are returned.- target
Vertex(optional, default:None) Target vertex, which must not be adjacent to
source.- max_n
int(optional, default:0) If positive, at most this number of separators is returned.
- g
- Returns:
- separators
listofnumpy.ndarray The sorted vertices of every separator.
- separators
See also
all_minimum_vertex_separatorsAll minimum vertex separators
is_minimal_separatorTest for minimal vertex separators
is_separatorTest for vertex separators
Notes
A minimal \(s\)-\(t\) separator is a set \(S\) of vertices, not containing \(s\) and \(t\), whose removal leaves no path between them, and of which no proper subset has this property. The components of the remaining graph that contain \(s\) and \(t\) are then both adjacent to every vertex of \(S\). The minimal separators of the graph are the sets that are minimal \(s\)-\(t\) separators for some pair \(s,t\); some of them may contain smaller separators of other pairs (see
is_minimal_separator()). The minimum separators returned byall_minimum_vertex_separators()are the smallest of them.The minimal \(s\)-\(t\) separators are found with the algorithm of Kloks and Kratsch [kloks-listing-1998]: the first is the neighborhood \(N(C_t)\) of the component \(C_t\) of \(G - N[s]\) that contains \(t\), where \(N[s]\) is \(s\) together with its neighbors, and every other is obtained from a separator \(S\) already found as \(N(C_t)\), with \(C_t\) the component of \(G - (S \cup N(x))\) that contains \(t\), for some \(x\in S\) not adjacent to \(t\). All minimal separators are found in the same way with the algorithm of Berry, Bordat, and Cogis [berry-generating-1999], which starts from the neighborhoods of the components of \(G - N[v]\) for every vertex \(v\), and obtains the others from those of \(G - (S\cup N(x))\) for every \(x \in S\). Both need \(O(V(V+E))\) time per separator found, whose number can grow exponentially with the size of the graph. The separators are generated in order of distance from the initial ones, and the expansions of each generation are performed in parallel.
@parallel@
References
[kloks-listing-1998]Ton Kloks and Dieter Kratsch, “Listing all minimal separators of a graph”, SIAM Journal on Computing 27, 605-613 (1998), DOI: 10.1137/S009753979427087X [sci-hub, @tor]
[berry-generating-1999]Anne Berry, Jean-Paul Bordat and Olivier Cogis, “Generating all the minimal separators of a graph”, in Graph-Theoretic Concepts in Computer Science (WG 1999), Lecture Notes in Computer Science 1665, 167-172 (1999), DOI: 10.1007/3-540-46784-X_17 [sci-hub, @tor]
Examples
>>> g = gt.Graph([(0, 1), (1, 2), (2, 3), (3, 4), (4, 1)], directed=False) >>> print(gt.all_minimal_separators(g)) [array([1], dtype=uint64), array([2, 4], dtype=uint64), array([1, 3], dtype=uint64)] >>> print(gt.all_minimal_separators(g, 2, 4)) [array([1, 3], dtype=uint64)]