antichains#
- graph_tool.structure.antichains(g)[git][source]#
Return an iterator over all antichains of a directed acyclic graph.
- Parameters:
- g
Graph Directed acyclic graph.
- g
- Returns:
- antichainsiterator over
numpy.ndarray Every set of vertices no two of which are joined by a directed path, including the empty set.
- antichainsiterator over
See also
all_topological_sortsAll topological orderings
topological_generationsTopological generation of every vertex
transitive_closureTransitive closure of a graph
Notes
Comparability is given by the transitive closure, stored as bitsets in memory \(O(V^2)\), and the antichains are generated by extending each one with later vertices incomparable to all of its own, in topological order [freese-free-1995]. Their number can grow exponentially.
References
[freese-free-1995]Ralph Freese, Jaroslav Ježek and J. B. Nation, “Free Lattices”, American Mathematical Society (1995), DOI: 10.1090/surv/042 [sci-hub, @tor]
Examples
>>> g = gt.Graph([(0, 1), (0, 2), (1, 3), (2, 3)]) >>> print(sorted(sorted(a.tolist()) for a in gt.antichains(g))) [[], [0], [1], [1, 2], [2], [3]]