![]() |
mutable
A Database System for Research and Fast Prototyping
|
An adjacency matrix for a given query graph. More...
#include <AdjacencyMatrix.hpp>
Data Structures | |
struct | Proxy |
A proxy to access single entries in the AdjacencyMatrix . More... | |
Public Member Functions | |
AdjacencyMatrix () | |
AdjacencyMatrix (std::size_t num_vertices) | |
AdjacencyMatrix (const AdjacencyMatrix &)=default | |
AdjacencyMatrix (AdjacencyMatrix &&)=default | |
AdjacencyMatrix & | operator= (AdjacencyMatrix &&)=default |
Proxy< true > | operator() (std::size_t i, std::size_t j) const |
Returns the bit at position (i, j) . | |
Proxy< false > | operator() (std::size_t i, std::size_t j) |
Returns the bit at position (i, j) . | |
Proxy< true > | at (std::size_t i, std::size_t j) const |
Proxy< false > | at (std::size_t i, std::size_t j) |
SmallBitset | reachable (SmallBitset src) const |
Computes the set of nodes reachable from src , i.e. the set of nodes reachable from any node in src . | |
SmallBitset | reachable (SmallBitset src, SmallBitset S) const |
Computes the set of nodes in S reachable from src , i.e. the set of nodes in S reachable from any node in src . | |
SmallBitset | neighbors (SmallBitset S) const |
Computes the neighbors of S . | |
bool | is_connected (SmallBitset S) const |
Returns true iff the subproblem S is connected. | |
bool | is_connected (SmallBitset left, SmallBitset right) const |
Returns true iff there is at least one edge (join) between left and right . | |
AdjacencyMatrix | transitive_closure_directed () const |
Computes the transitive closure of this adjacency matrix. | |
AdjacencyMatrix | transitive_closure_undirected () const |
Computes the transitive closure of this adjacency matrix. | |
void | for_each_CSG_undirected (SmallBitset super, SmallBitset source, std::function< void(SmallBitset)> callback) const |
Enumerate all connected subgraphs (CSGs) of the graph induced by vertex super set super , starting only from nodes in source . | |
void | for_each_CSG_undirected (SmallBitset super, std::function< void(SmallBitset)> callback) const |
Enumerate all connected subgraphs (CSGs) of the graph induced by vertex super set super . | |
void | for_each_CSG_pair_undirected (SmallBitset super, std::function< void(SmallBitset, SmallBitset)> callback) const |
Enumerate all pairs of connected subgraphs (CSGs) that are connected by at least one edge. | |
AdjacencyMatrix | minimum_spanning_forest (std::function< double(std::size_t, std::size_t)> weight) const |
Computes the minimum spanning forest for this graph. | |
AdjacencyMatrix | tree_directed_away_from (SmallBitset root) |
Computes an AdjacencyMatrix with all edges directed away from root . | |
bool | operator== (const AdjacencyMatrix &other) const |
Compares two AdjacencyMatrix s element-wise. | |
bool | operator!= (const AdjacencyMatrix &other) const |
void | print_fixed_length (std::ostream &out, unsigned length) const |
void | dump (std::ostream &out) const |
void | dump () const |
Private Attributes | |
std::array< SmallBitset, SmallBitset::CAPACITY > | m_ |
matrix entries | |
std::size_t | num_vertices_ = 0 |
number of sources of the QueryGraph represented by this matrix | |
Friends | |
M_LCOV_EXCL_START friend std::ostream & | operator<< (std::ostream &out, const AdjacencyMatrix &M) |
std::string | to_string (const AdjacencyMatrix &M) |
An adjacency matrix for a given query graph.
Represents the join graph.
Definition at line 10 of file AdjacencyMatrix.hpp.
|
inline |
Definition at line 65 of file AdjacencyMatrix.hpp.
|
inline |
Definition at line 66 of file AdjacencyMatrix.hpp.
|
explicitdefault |
|
default |
|
inline |
Definition at line 85 of file AdjacencyMatrix.hpp.
|
inline |
Definition at line 79 of file AdjacencyMatrix.hpp.
void AdjacencyMatrix::dump | ( | ) | const |
M_LCOV_EXCL_START void AdjacencyMatrix::dump | ( | std::ostream & | out | ) | const |
Definition at line 139 of file AdjacencyMatrix.cpp.
|
inline |
Enumerate all pairs of connected subgraphs (CSGs) that are connected by at least one edge.
Requires that this matrix is symmetric.
Definition at line 190 of file AdjacencyMatrix.hpp.
References m::SmallBitset::hi(), and m::SmallBitset::mask_to_lo().
Referenced by generate_correlated_cardinalities(), generate_uncorrelated_cardinalities(), m::pe::DPccp::operator()(), and m::Optimizer::optimize_join_order().
|
inline |
Enumerate all connected subgraphs (CSGs) of the graph induced by vertex super set super
, starting only from nodes in source
.
Definition at line 158 of file AdjacencyMatrix.hpp.
References m::SmallBitset::begin(), m::SmallBitset::end(), m::SmallBitset::is_singleton(), m::least_subset(), M_insist, m::SmallBitset::mask_to_lo(), and m::next_subset().
Referenced by main(), and m::Optimizer::optimize_join_order().
|
inline |
Enumerate all connected subgraphs (CSGs) of the graph induced by vertex super set super
.
Requires that this matrix is symmetric.
Definition at line 184 of file AdjacencyMatrix.hpp.
|
inline |
Returns true
iff there is at least one edge (join) between left
and right
.
Definition at line 136 of file AdjacencyMatrix.hpp.
References m::SmallBitset::empty().
|
inline |
Returns true
iff the subproblem S
is connected.
S
is connected iff any node in S
can reach all other nodes of S
using only nodes in S
. Assumes AdjacencyMatrix
is symmetric, i.e. edges are undirected.
Definition at line 133 of file AdjacencyMatrix.hpp.
References m::SmallBitset::begin().
Referenced by m::pe::GOO::for_each_join(), generate_uncorrelated_cardinalities(), IKKBZ::linearize(), m::MinCutAGaT::min_cut_advanced_generate_and_test(), m::pe::hs::expansions::BottomUpComplete::operator()(), DPsize::operator()(), DPsizeOpt::operator()(), DPsizeSub::operator()(), DPsub::operator()(), DPsubOpt::operator()(), LinearizedDP::operator()(), and TDbasic::PlanGen().
AdjacencyMatrix AdjacencyMatrix::minimum_spanning_forest | ( | std::function< double(std::size_t, std::size_t)> | weight | ) | const |
Computes the minimum spanning forest for this graph.
Expects the graph to be undirected, meaning that the AdjacencyMatrix
must be symmetric.
Definition at line 64 of file AdjacencyMatrix.cpp.
References m::SmallBitset::All(), m::SmallBitset::begin(), m::SmallBitset::is_singleton(), M_insist, neighbors(), num_vertices_, and m::SmallBitset::Singleton().
Referenced by IKKBZ::linearize().
|
inline |
Computes the neighbors of S
.
Nodes from S
are not part of the neighborhood.
Definition at line 123 of file AdjacencyMatrix.hpp.
Referenced by m::pe::hs::goo_path_completion(), m::pe::hs::heuristic_search(), IKKBZ::linearize(), m::MinCutAGaT::min_cut_advanced_generate_and_test(), minimum_spanning_forest(), m::pe::hs::heuristics::bottomup_lookahead_cheapest< PlanTable, State >::operator()(), m::pe::hs::heuristics::GOO< PlanTable, State, BottomUp >::operator()(), m::pe::hs::expansions::BottomUpComplete::operator()(), m::pe::GOO::operator()(), and tree_directed_away_from().
|
inline |
Definition at line 219 of file AdjacencyMatrix.hpp.
|
inline |
Returns the bit at position (i, j)
.
Both i
and j
must be in bounds.
Definition at line 77 of file AdjacencyMatrix.hpp.
|
inline |
Returns the bit at position (i, j)
.
Both i
and j
must be in bounds.
Definition at line 74 of file AdjacencyMatrix.hpp.
|
default |
|
inline |
Compares two AdjacencyMatrix
s element-wise.
Definition at line 211 of file AdjacencyMatrix.hpp.
References m_, and num_vertices_.
|
inline |
Definition at line 233 of file AdjacencyMatrix.hpp.
References M_insist.
|
inline |
Computes the set of nodes reachable from src
, i.e. the set of nodes reachable from any node in src
.
Definition at line 92 of file AdjacencyMatrix.hpp.
Referenced by m::MinCutAGaT::min_cut_advanced_generate_and_test().
|
inline |
Computes the set of nodes in S
reachable from src
, i.e. the set of nodes in S
reachable from any node in src
.
Definition at line 108 of file AdjacencyMatrix.hpp.
AdjacencyMatrix AdjacencyMatrix::transitive_closure_directed | ( | ) | const |
Computes the transitive closure of this adjacency matrix.
That is, compute for each pair of vertices *(i, j)* whether j can be reached from i by any finite path. Treats edges as directed and hence does not exploit symmetry.
Definition at line 13 of file AdjacencyMatrix.cpp.
References m_, M_insist, num_vertices_, and m::SmallBitset::Singleton().
AdjacencyMatrix AdjacencyMatrix::transitive_closure_undirected | ( | ) | const |
Computes the transitive closure of this adjacency matrix.
That is, compute for each pair of vertices *(i, j)* whether j can be reached from i by any finite path. Expects that this AdjacencyMatrix
is symmetric, i.e. that the original graph is undirected.
Definition at line 41 of file AdjacencyMatrix.cpp.
References m_, M_insist, and num_vertices_.
AdjacencyMatrix AdjacencyMatrix::tree_directed_away_from | ( | SmallBitset | root | ) |
Computes an AdjacencyMatrix
with all edges directed away from root
.
Requires that the graph is a tree, i.e. connected and acyclic.
Definition at line 122 of file AdjacencyMatrix.cpp.
References m::SmallBitset::empty(), m::SmallBitset::is_singleton(), m_, M_insist, neighbors(), num_vertices_, and m::X.
|
friend |
Definition at line 222 of file AdjacencyMatrix.hpp.
|
friend |
Definition at line 227 of file AdjacencyMatrix.hpp.
|
private |
matrix entries
Definition at line 61 of file AdjacencyMatrix.hpp.
Referenced by operator==(), transitive_closure_directed(), transitive_closure_undirected(), and tree_directed_away_from().
|
private |
number of sources of the QueryGraph
represented by this matrix
Definition at line 62 of file AdjacencyMatrix.hpp.
Referenced by minimum_spanning_forest(), operator==(), transitive_closure_directed(), transitive_closure_undirected(), and tree_directed_away_from().