|
Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
|
Classes | |
| struct | Union_Find |
| Union-find over the nodes 0 .. n - 1. More... | |
Enumerations | |
| enum class | Euler { None , Path , Cycle } |
| What kind of Eulerian walk the multigraph has. More... | |
Functions | |
| int | degree (const Spec &s, int x) |
| The degree of x: a loop counts 2. | |
| std::vector< int > | component_of (const Spec &s, int skip_node=-1, int skip_arc=-1) |
| The number of the component of each node, as that of its root, of the graph without the node skip_node and the arc skip_arc (-1: none) | |
| int | components (const Spec &s, int skip_node=-1, int skip_arc=-1) |
| The number of components, without the node skip_node and the arc skip_arc. | |
| std::set< int > | cut_nodes (const Spec &s) |
| The nodes whose removal splits their component. | |
| std::set< int > | cut_nodes (const Spec &s, int start) |
| The cut nodes of the component of start. | |
| std::set< int > | bridges (const Spec &s) |
| The arcs, by number, whose removal splits their component. | |
| bool | has_cycle (const Spec &s) |
| Whether the multigraph, not directed, has a cycle. | |
| bool | on_cycle (const Spec &s, int x) |
| Whether the node x lies on a cycle of the multigraph, not directed. | |
| bool | is_bipartite (const Spec &s) |
| Whether the multigraph, not directed, has two colors with no arc inside one (a loop is an odd cycle) | |
| int | max_matching (const Spec &s) |
| The size of a maximum matching, by brute force over the subsets of the arcs; loops never match. | |
| bool | is_matching (const Spec &s, const std::vector< int > &arcs) |
| Whether the arcs, by number, form a matching of s. | |
| long long | min_spanning_forest_weight (const Spec &s) |
| The weight of a minimum spanning forest: Kruskal on the list of arcs. | |
| std::vector< std::vector< bool > > | closure (const Spec &s, bool directed) |
| reach[u][v]: v is reached from u by a directed path of one arc or more (in a graph that is not directed, give directed = false) | |
| bool | reaches (const std::vector< std::vector< bool > > &r, int u, int v) |
| Whether there is a path, of zero arcs or more, from u to v. | |
| std::vector< int > | scc_partition (const Spec &s) |
| The strongly connected components, as the smallest node of the component of each node. | |
| bool | is_dag (const Spec &s) |
| Whether the digraph has no directed cycle (a loop is one) | |
| bool | is_topological_order (const Spec &s, const std::vector< int > &order) |
| Whether order, a sequence of all the nodes, is a topological order. | |
| std::vector< std::vector< int > > | hops (const Spec &s, bool directed) |
| hops[u][v]: the least number of arcs of a path from u to v, 0 from u to itself and -1 if there is no path | |
| Spec | reversed (const Spec &s) |
| The spec with each arc reversed; the arcs keep their numbers. | |
| Spec | without (const Spec &s, unsigned long hidden, std::vector< int > &orig) |
| The spec without the arcs whose numbers are set in hidden, with orig[i] the number in s of its i-th arc. | |
| std::vector< int > | kahn_ranks (const Spec &s) |
| The rank that Kahn's algorithm gives each node of a digraph: 0 for a node without arcs in, else 1 + the largest rank of its predecessors. | |
| std::vector< std::vector< bool > > | dominators (const Spec &s, int root) |
| dom[d][v]: d dominates v from root in a digraph, that is, v is reached from root and every path from root to v goes through d. | |
| std::vector< int > | immediate_dominators (const Spec &s, int root) |
| The immediate dominator of each node from root: the strict dominator that all the others dominate; -1 for root and the nodes not reached. | |
| std::vector< std::set< int > > | dominance_frontiers (const Spec &s, int root) |
| The dominance frontier of each node from root: y is in that of x if x dominates a predecessor of y and does not strictly dominate y. | |
| bool | is_euler_walk (const Spec &s, const std::vector< int > &arcs, bool directed, bool closed) |
| Whether arcs, by number, walk every arc of s once, each from the node where the one before ended (from either end if not directed), back to where they began if closed. | |
| Euler | euler_class (const Spec &s, bool directed) |
| The Eulerian class of s: the arcs must be in one component (weakly, in a digraph), and the degrees even, or balanced, everywhere but at the two ends of a path. | |
| long long | saturated_add (long long a, long long b) |
| a + b, kept within the range of long long | |
| std::vector< std::vector< long long > > | shortest_distances (const Spec &s, bool directed, bool &neg) |
| Floyd on a matrix of long long: the shortest distances, Inf where there is no path, and neg set if there is a negative cycle; in a graph that is not directed each arc goes both ways. | |
| bool | is_negative_cycle (const Spec &s, const std::vector< int > &arcs, bool directed) |
| Whether the arcs, by number, form a closed walk of s whose weights add up to less than zero; in a graph that is not directed each arc may be walked either way. | |
| long long | max_flow (const Spec &s, int src, int snk) |
| The maximum flow from src to snk, by Edmonds-Karp on the matrix of the capacities w (loops carry nothing) | |
Variables | |
| constexpr long long | Inf = std::numeric_limits<long long>::max() |
| No distance, in the matrices of the oracles. | |
|
strong |
What kind of Eulerian walk the multigraph has.
| Enumerator | |
|---|---|
| None | |
| Path | |
| Cycle | |
Definition at line 539 of file graph_oracles.H.
|
inline |
The arcs, by number, whose removal splits their component.
Definition at line 152 of file graph_oracles.H.
References graph_harness::Spec::arcs, components(), and r.
Referenced by TYPED_TEST().
|
inline |
reach[u][v]: v is reached from u by a directed path of one arc or more (in a graph that is not directed, give directed = false)
Definition at line 282 of file graph_oracles.H.
References graph_harness::Spec::arcs, k, graph_harness::Spec::n, and r.
Referenced by is_dag(), kahn_ranks(), scc_partition(), TYPED_TEST(), and TYPED_TEST().
|
inline |
The number of the component of each node, as that of its root, of the graph without the node skip_node and the arc skip_arc (-1: none)
Definition at line 100 of file graph_oracles.H.
References graph_harness::Spec::arcs, graph_oracles::Union_Find::find(), graph_oracles::Union_Find::join(), and graph_harness::Spec::n.
Referenced by components(), cut_nodes(), on_cycle(), TYPED_TEST(), and TYPED_TEST().
|
inline |
The number of components, without the node skip_node and the arc skip_arc.
Definition at line 119 of file graph_oracles.H.
References component_of(), and graph_harness::Spec::n.
Referenced by bridges(), cut_nodes(), TYPED_TEST(), and TYPED_TEST().
|
inline |
The nodes whose removal splits their component.
Definition at line 130 of file graph_oracles.H.
References components(), graph_harness::Spec::n, and r.
Referenced by cut_nodes(), and TYPED_TEST().
|
inline |
The cut nodes of the component of start.
Definition at line 141 of file graph_oracles.H.
References component_of(), cut_nodes(), and r.
|
inline |
The degree of x: a loop counts 2.
Definition at line 90 of file graph_oracles.H.
References graph_harness::Spec::arcs.
Referenced by euler_class().
|
inline |
The dominance frontier of each node from root: y is in that of x if x dominates a predecessor of y and does not strictly dominate y.
Definition at line 484 of file graph_oracles.H.
References Aleph::and, graph_harness::Spec::arcs, Aleph::df(), dominators(), graph_harness::Spec::n, and root().
Referenced by TYPED_TEST().
|
inline |
dom[d][v]: d dominates v from root in a digraph, that is, v is reached from root and every path from root to v goes through d.
A node that is reached dominates itself.
Definition at line 426 of file graph_oracles.H.
References Aleph::all(), Aleph::and, graph_harness::Spec::arcs, graph_harness::Spec::n, and root().
Referenced by dominance_frontiers(), immediate_dominators(), and TYPED_TEST().
The Eulerian class of s: the arcs must be in one component (weakly, in a digraph), and the degrees even, or balanced, everywhere but at the two ends of a path.
Without arcs, the empty walk is a cycle.
Definition at line 544 of file graph_oracles.H.
References Aleph::and, graph_harness::Spec::arcs, Cycle, degree(), graph_oracles::Union_Find::find(), graph_oracles::Union_Find::join(), graph_harness::Spec::n, None, out, and Path.
Referenced by TYPED_TEST(), and TYPED_TEST().
|
inline |
Whether the multigraph, not directed, has a cycle.
Definition at line 163 of file graph_oracles.H.
References graph_harness::Spec::arcs, graph_oracles::Union_Find::join(), and graph_harness::Spec::n.
Referenced by TYPED_TEST(), and TYPED_TEST().
|
inline |
hops[u][v]: the least number of arcs of a path from u to v, 0 from u to itself and -1 if there is no path
Definition at line 355 of file graph_oracles.H.
References Aleph::and, graph_harness::Spec::arcs, h, k, and graph_harness::Spec::n.
|
inline |
The immediate dominator of each node from root: the strict dominator that all the others dominate; -1 for root and the nodes not reached.
Definition at line 463 of file graph_oracles.H.
References Aleph::and, dominators(), graph_harness::Spec::n, and root().
Referenced by TYPED_TEST().
|
inline |
Whether the multigraph, not directed, has two colors with no arc inside one (a loop is an odd cycle)
Definition at line 191 of file graph_oracles.H.
References graph_harness::Spec::arcs, Aleph::color(), k, graph_harness::Spec::n, root(), and y.
Referenced by TYPED_TEST().
|
inline |
Whether the digraph has no directed cycle (a loop is one)
Definition at line 326 of file graph_oracles.H.
References closure(), graph_harness::Spec::n, and r.
Referenced by TYPED_TEST(), and TYPED_TEST().
|
inline |
Whether arcs, by number, walk every arc of s once, each from the node where the one before ended (from either end if not directed), back to where they began if closed.
Definition at line 499 of file graph_oracles.H.
References Aleph::and, arcs, and graph_harness::Spec::arcs.
Referenced by TYPED_TEST(), and TYPED_TEST().
|
inline |
Whether the arcs, by number, form a matching of s.
Definition at line 252 of file graph_oracles.H.
References arcs, graph_harness::Spec::arcs, and graph_harness::Spec::n.
Referenced by TYPED_TEST().
|
inline |
Whether the arcs, by number, form a closed walk of s whose weights add up to less than zero; in a graph that is not directed each arc may be walked either way.
Definition at line 633 of file graph_oracles.H.
References Aleph::and, arcs, graph_harness::Spec::arcs, and graph_harness::Spec::w.
|
inline |
Whether order, a sequence of all the nodes, is a topological order.
Definition at line 336 of file graph_oracles.H.
References graph_harness::Spec::arcs, and graph_harness::Spec::n.
Referenced by TYPED_TEST().
|
inline |
The rank that Kahn's algorithm gives each node of a digraph: 0 for a node without arcs in, else 1 + the largest rank of its predecessors.
The nodes that a cycle reaches never come out, and have -1.
Definition at line 405 of file graph_oracles.H.
References Aleph::and, graph_harness::Spec::arcs, closure(), graph_harness::Spec::n, r, and reaches().
Referenced by TYPED_TEST().
|
inline |
The maximum flow from src to snk, by Edmonds-Karp on the matrix of the capacities w (loops carry nothing)
Definition at line 670 of file graph_oracles.H.
References Aleph::and, graph_harness::Spec::arcs, h, Inf, graph_harness::Spec::n, and graph_harness::Spec::w.
|
inline |
The size of a maximum matching, by brute force over the subsets of the arcs; loops never match.
Definition at line 224 of file graph_oracles.H.
References Aleph::and, graph_harness::Spec::arcs, m, graph_harness::Spec::n, and Aleph::size().
Referenced by TYPED_TEST().
|
inline |
The weight of a minimum spanning forest: Kruskal on the list of arcs.
Definition at line 266 of file graph_oracles.H.
References graph_harness::Spec::arcs, graph_oracles::Union_Find::join(), graph_harness::Spec::n, and graph_harness::Spec::w.
|
inline |
Whether the node x lies on a cycle of the multigraph, not directed.
Definition at line 173 of file graph_oracles.H.
References Aleph::and, graph_harness::Spec::arcs, and component_of().
Referenced by TYPED_TEST().
|
inline |
Whether there is a path, of zero arcs or more, from u to v.
Definition at line 301 of file graph_oracles.H.
References r.
Referenced by kahn_ranks(), and TYPED_TEST().
The spec with each arc reversed; the arcs keep their numbers.
Definition at line 376 of file graph_oracles.H.
References r.
Referenced by TYPED_TEST().
|
inline |
a + b, kept within the range of long long
Definition at line 592 of file graph_oracles.H.
References Aleph::and.
Referenced by shortest_distances().
|
inline |
The strongly connected components, as the smallest node of the component of each node.
Definition at line 308 of file graph_oracles.H.
References Aleph::and, closure(), graph_harness::Spec::n, and r.
Referenced by TYPED_TEST().
|
inline |
Floyd on a matrix of long long: the shortest distances, Inf where there is no path, and neg set if there is a negative cycle; in a graph that is not directed each arc goes both ways.
The sums are saturated, so weights up to 2^40 in absolute value are exact on the graphs of the harness, negative cycles included.
Definition at line 607 of file graph_oracles.H.
References Aleph::and, graph_harness::Spec::arcs, Inf, k, graph_harness::Spec::n, saturated_add(), and graph_harness::Spec::w.
Referenced by TEST().
|
inline |
The spec without the arcs whose numbers are set in hidden, with orig[i] the number in s of its i-th arc.
Definition at line 386 of file graph_oracles.H.
References graph_harness::Spec::arcs, graph_harness::Spec::n, r, and graph_harness::Spec::w.
Referenced by TYPED_TEST().
|
constexpr |
No distance, in the matrices of the oracles.
Definition at line 589 of file graph_oracles.H.
Referenced by max_flow(), shortest_distances(), and TEST().