PandA-2024.02
clique_covering_graph.hpp
Go to the documentation of this file.
1 /*
2  *
3  * _/_/_/ _/_/ _/ _/ _/_/_/ _/_/
4  * _/ _/ _/ _/ _/_/ _/ _/ _/ _/ _/
5  * _/_/_/ _/_/_/_/ _/ _/_/ _/ _/ _/_/_/_/
6  * _/ _/ _/ _/ _/ _/ _/ _/ _/
7  * _/ _/ _/ _/ _/ _/_/_/ _/ _/
8  *
9  * ***********************************************
10  * PandA Project
11  * URL: http://panda.dei.polimi.it
12  * Politecnico di Milano - DEIB
13  * System Architectures Group
14  * ***********************************************
15  * Copyright (C) 2004-2024 Politecnico di Milano
16  *
17  * This file is part of the PandA framework.
18  *
19  * The PandA framework is free software; you can redistribute it and/or modify
20  * it under the terms of the GNU General Public License as published by
21  * the Free Software Foundation; either version 3 of the License, or
22  * (at your option) any later version.
23  *
24  * This program is distributed in the hope that it will be useful,
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27  * GNU General Public License for more details.
28  *
29  * You should have received a copy of the GNU General Public License
30  * along with this program. If not, see <http://www.gnu.org/licenses/>.
31  *
32  */
38 #ifndef CLIQUE_COVERING_GRAPH_HPP
39 #define CLIQUE_COVERING_GRAPH_HPP
40 
42 #include <boost/config.hpp>
43 #include <boost/graph/adjacency_matrix.hpp>
44 #include <boost/graph/filtered_graph.hpp>
45 #include <boost/graph/graph_utility.hpp>
46 #include <boost/graph/graphviz.hpp>
47 #include <boost/graph/incremental_components.hpp>
48 #include <boost/graph/properties.hpp>
49 #include <boost/graph/topological_sort.hpp>
50 #include <boost/pending/disjoint_sets.hpp>
51 #include <boost/version.hpp>
52 
53 #include "custom_map.hpp"
54 #include "custom_set.hpp"
55 #include "refcount.hpp"
56 
58 template <typename Graph>
60 {
61  public:
62  using vertex_descriptor = typename boost::graph_traits<Graph>::vertex_descriptor;
66  {
67  }
70  {
71  }
73  bool operator()(const vertex_descriptor& v) const
74  {
75  if(all)
76  {
77  return true;
78  }
79  else
80  {
81  return support->find(v) != support->end();
82  }
83  }
84 
85  private:
86  bool all;
88 };
89 
91 template <typename Graph>
93 {
94  private:
96  int selector;
97 
99  Graph* g;
100 
101  bool all;
102 
103  public:
109  cc_compatibility_graph_edge_selector(const int _selector, Graph* _g) : selector(_selector), g(_g), all(false)
110  {
111  }
112 
114  cc_compatibility_graph_edge_selector() : selector(0), g(nullptr), all(true)
115  {
116  }
117 
119  template <typename Edge>
120  bool operator()(const Edge& e) const
121  {
122  if(all)
123  {
124  return true;
125  }
126  else
127  {
128  return selector & (*g)[e].selector;
129  }
130  }
131 };
132 
134 {
135  public:
137  int selector;
138 
140  int weight;
141 
142  edge_compatibility_selector() : selector(0), weight(0)
143  {
144  }
145 
151  edge_compatibility_selector(int _selector, int _weight) : selector(_selector), weight(_weight)
152  {
153  }
154 };
155 
158  boost::adjacency_matrix<boost::undirectedS, boost::property<boost::vertex_index_t, std::size_t>,
160 
163  boost::filtered_graph<boost_cc_compatibility_graph,
166 
169 
171 using C_vertex = boost::graph_traits<cc_compatibility_graph>::vertex_descriptor;
172 using C_outEdgeIterator = boost::graph_traits<cc_compatibility_graph>::out_edge_iterator;
173 
175 using VertexIndex = boost::graph_traits<boost_cc_compatibility_graph>::vertices_size_type;
179 using rank_pmap_type = boost::iterator_property_map<std::vector<VertexIndex>::iterator, vertex_index_pmap_t>;
181 using pred_pmap_type = boost::iterator_property_map<std::vector<C_vertex>::iterator, vertex_index_pmap_t>;
182 
183 //*************** definitions used in randomized clique covering
184 
185 using RVertexIndex = boost::graph_traits<boost_cc_compatibility_graph>::vertices_size_type;
186 using REdge = boost::graph_traits<boost_cc_compatibility_graph>::edge_descriptor;
187 
188 /* VERSIONE PRECEDENTE
189 typedef RVertexIndex* RRank;
190 typedef C_vertex* RParent;
191 typedef boost::disjoint_sets<RRank, RParent, boost::find_with_full_path_compression> RDisjointSet;
192 */
193 
194 using RDisjointSet = boost::disjoint_sets<rank_pmap_type, pred_pmap_type>;
195 
196 #endif
boost::graph_traits< cc_compatibility_graph >::out_edge_iterator C_outEdgeIterator
boost::graph_traits< boost_cc_compatibility_graph >::edge_descriptor REdge
int selector
The selector associated with the filtered graph.
redefinition of map to manage ordered/unordered structures
boost::iterator_property_map< std::vector< VertexIndex >::iterator, vertex_index_pmap_t > rank_pmap_type
rank property map definition
boost::adjacency_matrix< boost::undirectedS, boost::property< boost::vertex_index_t, std::size_t >, edge_compatibility_selector > boost_cc_compatibility_graph
bulk compatibility graph
Predicate functor object used to select the proper set of edges.
boost::graph_traits< boost_cc_compatibility_graph >::vertices_size_type VertexIndex
vertices index type
bool operator()(const Edge &e) const
edge selector operator
cc_compatibility_graph_vertex_selector(SET_container *_support)
constructor
redefinition of set to manage ordered/unordered structures
boost::graph_traits< boost_cc_compatibility_graph >::vertices_size_type RVertexIndex
cc_compatibility_graph_edge_selector()
all edges selector
int selector
The selector associated with the edge.
Template definition of refcount.
typename boost::graph_traits< Graph >::vertex_descriptor vertex_descriptor
bool operator()(const vertex_descriptor &v) const
selector operator
boost::property_map< boost_cc_compatibility_graph, boost::vertex_index_t >::type vertex_index_pmap_t
index map type
Template borrowed from the ANTLR library by Terence Parr (http://www.jGuru.com - Software rights: htt...
Definition: refcount.hpp:94
boost::filtered_graph< boost_cc_compatibility_graph, cc_compatibility_graph_edge_selector< boost_cc_compatibility_graph >, cc_compatibility_graph_vertex_selector< boost_cc_compatibility_graph > > cc_compatibility_graph
compatibility graph
boost::disjoint_sets< rank_pmap_type, pred_pmap_type > RDisjointSet
boost::iterator_property_map< std::vector< C_vertex >::iterator, vertex_index_pmap_t > pred_pmap_type
parent property map definition
edge_compatibility_selector(int _selector, int _weight)
Constructor with selector.
boost::graph_traits< cc_compatibility_graph >::vertex_descriptor C_vertex
cc_compatibility_graph vertex
cc_compatibility_graph_edge_selector(const int _selector, Graph *_g)
Constructor for filtering only on selector.

Generated on Mon Feb 12 2024 13:02:50 for PandA-2024.02 by doxygen 1.8.13