@@ -36,18 +36,24 @@ namespace osp {
3636
3737// summing up weights
3838
39- template <typename index_type, typename workw_type, typename memw_type, typename commw_type >
40- workw_type compute_total_vertex_work_weight (const Hypergraph<index_type, workw_type, memw_type, commw_type> & hgraph)
39+ template <typename hypergraph_t >
40+ typename hypergraph_t ::vertex_work_weight_type compute_total_vertex_work_weight (const hypergraph_t & hgraph)
4141{
42+ using index_type = typename hypergraph_t ::vertex_idx;
43+ using workw_type = typename hypergraph_t ::vertex_work_weight_type;
44+
4245 workw_type total = 0 ;
4346 for (index_type node = 0 ; node < hgraph.num_vertices (); ++node)
4447 total += hgraph.get_vertex_work_weight (node);
4548 return total;
4649}
4750
48- template <typename index_type, typename workw_type, typename memw_type, typename commw_type >
49- memw_type compute_total_vertex_memory_weight (const Hypergraph<index_type, workw_type, memw_type, commw_type> & hgraph)
51+ template <typename hypergraph_t >
52+ typename hypergraph_t ::vertex_mem_weight_type compute_total_vertex_memory_weight (const hypergraph_t & hgraph)
5053{
54+ using index_type = typename hypergraph_t ::vertex_idx;
55+ using memw_type = typename hypergraph_t ::vertex_mem_weight_type;
56+
5157 memw_type total = 0 ;
5258 for (index_type node = 0 ; node < hgraph.num_vertices (); ++node)
5359 total += hgraph.get_vertex_memory_weight (node);
@@ -57,19 +63,22 @@ memw_type compute_total_vertex_memory_weight(const Hypergraph<index_type, workw_
5763
5864// get induced subhypergraph
5965
60- template <typename index_type, typename workw_type, typename memw_type, typename commw_type >
61- Hypergraph<index_type, workw_type, memw_type, commw_type> create_induced_hypergraph (const Hypergraph<index_type, workw_type, memw_type, commw_type> & hgraph, const std::vector<bool >& include)
66+ template <typename hypergraph_t >
67+ hypergraph_t create_induced_hypergraph (const hypergraph_t & hgraph, const std::vector<bool >& include)
6268{
6369 if (include.size () != hgraph.num_vertices ())
6470 throw std::invalid_argument (" Invalid Argument while extracting induced hypergraph: input bool array has incorrect size." );
6571
72+ using index_type = typename hypergraph_t ::vertex_idx;
73+
74+
6675 std::vector<index_type> new_index (hgraph.num_vertices ());
6776 unsigned current_index = 0 ;
6877 for (index_type node = 0 ; node < hgraph.num_vertices (); ++node)
6978 if (include[node])
7079 new_index[node] = current_index++;
7180
72- Hypergraph<index_type, workw_type, memw_type, commw_type> new_hgraph (current_index, 0 );
81+ hypergraph_t new_hgraph (current_index, 0 );
7382 for (index_type node = 0 ; node < hgraph.num_vertices (); ++node)
7483 if (include[node])
7584 {
@@ -97,15 +106,20 @@ Hypergraph<index_type, workw_type, memw_type, commw_type> create_induced_hypergr
97106
98107// conversion
99108
100- template <typename index_type, typename workw_type, typename memw_type, typename commw_type , typename Graph_t>
101- Hypergraph<index_type, workw_type, memw_type, commw_type> convert_from_cdag_as_dag (const Graph_t& dag)
109+ template <typename hypergraph_t , typename Graph_t>
110+ hypergraph_t convert_from_cdag_as_dag (const Graph_t& dag)
102111{
112+ using index_type = typename hypergraph_t ::vertex_idx;
113+ using workw_type = typename hypergraph_t ::vertex_work_weight_type;
114+ using memw_type = typename hypergraph_t ::vertex_mem_weight_type;
115+ using commw_type = typename hypergraph_t ::vertex_comm_weight_type;
116+
103117 static_assert (std::is_same_v<vertex_idx_t <Graph_t>, index_type>, " Index type mismatch, cannot convert DAG to hypergraph." );
104118 static_assert (std::is_same_v<v_workw_t <Graph_t>, workw_type>, " Work weight type mismatch, cannot convert DAG to hypergraph." );
105119 static_assert (std::is_same_v<v_memw_t <Graph_t>, memw_type>, " Memory weight type mismatch, cannot convert DAG to hypergraph." );
106120 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." );
107121
108- Hypergraph<index_type, workw_type, memw_type, commw_type> hgraph (dag.num_vertices (), 0 );
122+ hypergraph_t hgraph (dag.num_vertices (), 0 );
109123 for (const auto &node : dag.vertices ())
110124 {
111125 hgraph.set_vertex_work_weight (node, dag.vertex_work_weight (node));
@@ -119,15 +133,20 @@ Hypergraph<index_type, workw_type, memw_type, commw_type> convert_from_cdag_as_d
119133 return hgraph;
120134}
121135
122- template <typename index_type, typename workw_type, typename memw_type, typename commw_type , typename Graph_t>
123- Hypergraph<index_type, workw_type, memw_type, commw_type> convert_from_cdag_as_hyperdag (const Graph_t& dag)
136+ template <typename hypergraph_t , typename Graph_t>
137+ hypergraph_t convert_from_cdag_as_hyperdag (const Graph_t& dag)
124138{
139+ using index_type = typename hypergraph_t ::vertex_idx;
140+ using workw_type = typename hypergraph_t ::vertex_work_weight_type;
141+ using memw_type = typename hypergraph_t ::vertex_mem_weight_type;
142+ using commw_type = typename hypergraph_t ::vertex_comm_weight_type;
143+
125144 static_assert (std::is_same_v<vertex_idx_t <Graph_t>, index_type>, " Index type mismatch, cannot convert DAG to hypergraph." );
126145 static_assert (std::is_same_v<v_workw_t <Graph_t>, workw_type>, " Work weight type mismatch, cannot convert DAG to hypergraph." );
127146 static_assert (std::is_same_v<v_memw_t <Graph_t>, memw_type>, " Memory weight type mismatch, cannot convert DAG to hypergraph." );
128147 static_assert (std::is_same_v<v_commw_t <Graph_t>, commw_type>, " Communication weight type mismatch, cannot convert DAG to hypergraph." );
129148
130- Hypergraph<index_type, workw_type, memw_type, commw_type> hgraph (dag.num_vertices (), 0 );
149+ hypergraph_t hgraph (dag.num_vertices (), 0 );
131150 for (const auto &node : dag.vertices ())
132151 {
133152 hgraph.set_vertex_work_weight (node, dag.vertex_work_weight (node));
0 commit comments