@@ -56,22 +56,13 @@ class Hypergraph {
5656 void set_vertex_memory_weight (index_type vertex_idx, memw_type weight);
5757 void set_hyperedge_weight (index_type hyperedge_idx, commw_type weight);
5858
59- workw_type compute_total_vertex_work_weight () const ;
60- memw_type compute_total_vertex_memory_weight () const ;
6159
6260 void clear ();
6361 void reset (index_type num_vertices_, index_type num_hyperedges_);
6462
6563 inline const std::vector<index_type> &get_incident_hyperedges (index_type vertex) const { return incident_hyperedges_to_vertex[vertex]; }
6664 inline const std::vector<index_type> &get_vertices_in_hyperedge (index_type hyperedge) const { return vertices_in_hyperedge[hyperedge]; }
6765
68- template <typename Graph_t>
69- void convert_from_cdag_as_dag (const Graph_t& dag);
70-
71- template <typename Graph_t>
72- void convert_from_cdag_as_hyperdag (const Graph_t& dag);
73-
74- Hypergraph<index_type, workw_type, memw_type, commw_type> create_induced_hypergraph (const std::vector<bool >& include) const ;
7566
7667 private:
7768 index_type Num_vertices = 0 , Num_hyperedges = 0 , Num_pins = 0 ;
@@ -157,23 +148,6 @@ void Hypergraph<index_type, workw_type, memw_type, commw_type>::set_hyperedge_we
157148 hyperedge_weights[hyperedge_idx] = weight;
158149}
159150
160- template <typename index_type, typename workw_type, typename memw_type, typename commw_type>
161- workw_type Hypergraph<index_type, workw_type, memw_type, commw_type>::compute_total_vertex_work_weight() const
162- {
163- workw_type total = 0 ;
164- for (index_type node = 0 ; node < Num_vertices; ++node)
165- total += vertex_work_weights[node];
166- return total;
167- }
168-
169- template <typename index_type, typename workw_type, typename memw_type, typename commw_type>
170- memw_type Hypergraph<index_type, workw_type, memw_type, commw_type>::compute_total_vertex_memory_weight() const
171- {
172- memw_type total = 0 ;
173- for (index_type node = 0 ; node < Num_vertices; ++node)
174- total += vertex_memory_weights[node];
175- return total;
176- }
177151
178152template <typename index_type, typename workw_type, typename memw_type, typename commw_type>
179153void Hypergraph<index_type, workw_type, memw_type, commw_type>::clear()
@@ -204,86 +178,5 @@ void Hypergraph<index_type, workw_type, memw_type, commw_type>::reset(index_type
204178 vertices_in_hyperedge.resize (num_hyperedges_);
205179}
206180
207- template <typename index_type, typename workw_type, typename memw_type, typename commw_type>
208- template <typename Graph_t>
209- void Hypergraph<index_type, workw_type, memw_type, commw_type>::convert_from_cdag_as_dag(const Graph_t& dag)
210- {
211- static_assert (std::is_same_v<vertex_idx_t <Graph_t>, index_type>, " Index type mismatch, cannot convert DAG to hypergraph." );
212- static_assert (std::is_same_v<v_workw_t <Graph_t>, workw_type>, " Work weight type mismatch, cannot convert DAG to hypergraph." );
213- static_assert (std::is_same_v<v_memw_t <Graph_t>, memw_type>, " Memory weight type mismatch, cannot convert DAG to hypergraph." );
214- static_assert (!has_edge_weights_v<Graph_t> || std::is_same_v<e_commw_t <Graph_t>, commw_type>, " Communication weight type mismatch, cannot convert DAG to hypergraph." );
215-
216- reset (dag.num_vertices (), 0 );
217- for (const auto &node : dag.vertices ())
218- {
219- set_vertex_work_weight (node, dag.vertex_work_weight (node));
220- set_vertex_memory_weight (node, dag.vertex_mem_weight (node));
221- for (const auto &child : dag.children (node))
222- if constexpr (has_edge_weights_v<Graph_t>)
223- add_hyperedge ({node, child}, dag.edge_comm_weight (edge_desc (node, child, dag).first ));
224- else
225- add_hyperedge ({node, child});
226- }
227- }
228-
229- template <typename index_type, typename workw_type, typename memw_type, typename commw_type>
230- template <typename Graph_t>
231- void Hypergraph<index_type, workw_type, memw_type, commw_type>::convert_from_cdag_as_hyperdag(const Graph_t& dag)
232- {
233- static_assert (std::is_same_v<vertex_idx_t <Graph_t>, index_type>, " Index type mismatch, cannot convert DAG to hypergraph." );
234- static_assert (std::is_same_v<v_workw_t <Graph_t>, workw_type>, " Work weight type mismatch, cannot convert DAG to hypergraph." );
235- static_assert (std::is_same_v<v_memw_t <Graph_t>, memw_type>, " Memory weight type mismatch, cannot convert DAG to hypergraph." );
236- static_assert (std::is_same_v<v_commw_t <Graph_t>, commw_type>, " Communication weight type mismatch, cannot convert DAG to hypergraph." );
237-
238- reset (dag.num_vertices (), 0 );
239- for (const auto &node : dag.vertices ())
240- {
241- set_vertex_work_weight (node, dag.vertex_work_weight (node));
242- set_vertex_memory_weight (node, dag.vertex_mem_weight (node));
243- if (dag.out_degree (node) == 0 )
244- continue ;
245- std::vector<index_type> new_hyperedge ({node});
246- for (const auto &child : dag.children (node))
247- new_hyperedge.push_back (child);
248- add_hyperedge (new_hyperedge, dag.vertex_comm_weight (node));
249- }
250- }
251-
252- template <typename index_type, typename workw_type, typename memw_type, typename commw_type>
253- Hypergraph<index_type, workw_type, memw_type, commw_type> Hypergraph<index_type, workw_type, memw_type, commw_type>::create_induced_hypergraph(const std::vector<bool >& include) const
254- {
255- if (include.size () != Num_vertices)
256- throw std::invalid_argument (" Invalid Argument while extracting induced hypergraph: input bool array has incorrect size." );
257-
258- std::vector<index_type> new_index (Num_vertices);
259- unsigned current_index = 0 ;
260- for (index_type node = 0 ; node < Num_vertices; ++node)
261- if (include[node])
262- new_index[node] = current_index++;
263-
264- Hypergraph<index_type, workw_type, memw_type, commw_type> hgraph (current_index, 0 );
265- for (index_type node = 0 ; node < Num_vertices; ++node)
266- if (include[node])
267- {
268- hgraph.set_vertex_work_weight (new_index[node], vertex_work_weights[node]);
269- hgraph.set_vertex_memory_weight (new_index[node], vertex_memory_weights[node]);
270- }
271-
272- for (index_type hyperedge = 0 ; hyperedge < Num_hyperedges; ++hyperedge)
273- {
274- unsigned nr_induced_pins = 0 ;
275- std::vector<index_type> induced_hyperedge;
276- for (index_type node : vertices_in_hyperedge[hyperedge])
277- if (include[node])
278- {
279- induced_hyperedge.push_back (new_index[node]);
280- ++nr_induced_pins;
281- }
282-
283- if (nr_induced_pins >= 2 )
284- hgraph.add_hyperedge (induced_hyperedge, hyperedge_weights[hyperedge]);
285- }
286- return hgraph;
287- }
288181
289182} // namespace osp
0 commit comments