33#ifndef UG_BASE_LIB_ALGEBRA_ORDERING_STRATEGIES_ALGORITHMS_BOOST_MINIMUM_DEGREE_ORDERING_H
34#define UG_BASE_LIB_ALGEBRA_ORDERING_STRATEGIES_ALGORITHMS_BOOST_MINIMUM_DEGREE_ORDERING_H
36#include <boost/graph/adjacency_list.hpp>
37#include <boost/graph/graph_traits.hpp>
38#include <boost/graph/properties.hpp>
40#include <boost/graph/minimum_degree_ordering.hpp>
54template <
typename TAlgebra,
typename O_t>
58 typedef typename TAlgebra::matrix_type
M_t;
59 typedef typename TAlgebra::vector_type
V_t;
60 typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS>
G_t;
76 unsigned e = boost::num_edges(
g);
87 else if(n*(n-1u)==e || e==0){
88 UG_LOG(
name() <<
"::compute: Graph is complete or edgeless!");
89 typename boost::graph_traits<G_t>::vertex_iterator vIt, vEnd;
95 std::vector<int> inverse_perm(n, 0);
96 std::vector<int> supernode_sizes(n, 1);
98 std::vector<int> degree(n, 0);
110 boost::minimum_degree_ordering
112 boost::make_iterator_property_map(°ree[0],
id, degree[0]),
115 boost::make_iterator_property_map(&supernode_sizes[0],
id, supernode_sizes[0]),
141 #ifdef UG_ENABLE_DEBUG_LOGS
145 unsigned rows = A->num_rows();
149 for(
unsigned i = 0; i < rows; i++){
150 for(
typename M_t::row_iterator conn = A->begin_row(i); conn != A->end_row(i); ++conn){
151 if(conn.value() != 0.0 && conn.index() != i){
152 boost::add_edge(i, conn.index(),
g);
159 UG_THROW(
name() <<
"::init: induced subgraph version not implemented yet!");
163 UG_THROW(
name() <<
"::init: induced subgraph version not implemented yet!");
166 virtual const char*
name()
const {
return "BoostMinimumDegreeOrdering";}
Definition smart_pointer.h:108
Definition boost_minimum_degree_ordering.h:56
TAlgebra::matrix_type M_t
Definition boost_minimum_degree_ordering.h:58
SmartPtr< IOrderingAlgorithm< TAlgebra, O_t > > clone()
Definition boost_minimum_degree_ordering.h:69
void init(M_t *A, const V_t &)
Definition boost_minimum_degree_ordering.h:135
virtual const char * name() const
Definition boost_minimum_degree_ordering.h:166
O_t o
Definition boost_minimum_degree_ordering.h:170
void init(M_t *A)
Definition boost_minimum_degree_ordering.h:139
void init(M_t *, const V_t &, const O_t &)
Definition boost_minimum_degree_ordering.h:158
void init(M_t *, const O_t &)
Definition boost_minimum_degree_ordering.h:162
TAlgebra::vector_type V_t
Definition boost_minimum_degree_ordering.h:59
void check()
Definition boost_minimum_degree_ordering.h:127
boost::adjacency_list< boost::vecS, boost::vecS, boost::bidirectionalS > G_t
Definition boost_minimum_degree_ordering.h:60
BoostMinimumDegreeOrdering()
Definition boost_minimum_degree_ordering.h:63
BoostMinimumDegreeOrdering(const BoostMinimumDegreeOrdering< TAlgebra, O_t > &parent)
clone constructor
Definition boost_minimum_degree_ordering.h:66
O_t & ordering()
Definition boost_minimum_degree_ordering.h:131
IOrderingAlgorithm< TAlgebra, O_t > baseclass
Definition boost_minimum_degree_ordering.h:61
void compute()
Definition boost_minimum_degree_ordering.h:74
G_t g
Definition boost_minimum_degree_ordering.h:169
Definition IOrderingAlgorithm.h:52
#define UG_THROW(msg)
Definition error.h:57
#define UG_LOG(msg)
Definition log.h:367
#define UG_COND_THROW(cond, msg)
UG_COND_THROW(cond, msg) : performs a UG_THROW(msg) if cond == true.
Definition error.h:61
std::pair< counting_iterator< size_t >, counting_iterator< size_t > > vertices(ug::BidirectionalMatrix< T > const &M)
Definition bidirectional_boost.h:60
int num_vertices(ug::BidirectionalMatrix< T > const &M)
Definition bidirectional_boost.h:70
SM_edge_weight_map< typename T::value_type, ug::BidirectionalMatrix< T > > get(edge_weight_t, ug::BidirectionalMatrix< T > const &g)
Definition bidirectional_boost.h:157
bool is_permutation(O_t &o)
Definition permutation_util.h:135
SmartPtr< T, FreePolicy > make_sp(T *inst)
returns a SmartPtr for the passed raw pointer
Definition smart_pointer.h:836