@@ -30,7 +30,8 @@ class Hypergraph {
3030 Hypergraph () = default ;
3131
3232 Hypergraph (unsigned num_vertices_, unsigned num_hyperedges_)
33- : Num_vertices(num_vertices_), Num_hyperedges(num_hyperedges_), vertex_weights(num_vertices_, 1 ), hyperedge_weights(num_hyperedges_, 1 ),
33+ : Num_vertices(num_vertices_), Num_hyperedges(num_hyperedges_), vertex_work_weights(num_vertices_, 1 ),
34+ vertex_memory_weights (num_vertices_, 1 ), hyperedge_weights(num_hyperedges_, 1 ),
3435 incident_hyperedges_to_vertex(num_vertices_), vertices_in_hyperedge(num_hyperedges_){}
3536
3637 Hypergraph (const Hypergraph &other) = default;
@@ -41,17 +42,20 @@ class Hypergraph {
4142 inline unsigned num_vertices () const { return Num_vertices; }
4243 inline unsigned num_hyperedges () const { return Num_hyperedges; }
4344 inline unsigned num_pins () const { return Num_pins; }
44- inline int get_vertex_weight (unsigned node) const { return vertex_weights[node]; }
45+ inline int get_vertex_work_weight (unsigned node) const { return vertex_work_weights[node]; }
46+ inline int get_vertex_memory_weight (unsigned node) const { return vertex_memory_weights[node]; }
4547 inline int get_hyperedge_weight (unsigned hyperedge) const { return hyperedge_weights[hyperedge]; }
4648
4749 void add_pin (unsigned vertex_idx, unsigned hyperedge_idx);
48- void add_vertex (int weight = 1 );
50+ void add_vertex (int work_weight = 1 , int memory_weight = 1 );
4951 void add_empty_hyperedge (int weight = 1 );
5052 void add_hyperedge (const std::vector<unsigned >& pins, int weight = 1 );
51- void set_vertex_weight (unsigned vertex_idx, int weight);
53+ void set_vertex_work_weight (unsigned vertex_idx, int weight);
54+ void set_vertex_memory_weight (unsigned vertex_idx, int weight);
5255 void set_hyperedge_weight (unsigned hyperedge_idx, int weight);
5356
54- int compute_total_vertex_weight () const ;
57+ int compute_total_vertex_work_weight () const ;
58+ int compute_total_vertex_memory_weight () const ;
5559
5660 void clear ();
5761 void reset (unsigned num_vertices_, unsigned num_hyperedges_);
@@ -68,7 +72,8 @@ class Hypergraph {
6872 private:
6973 unsigned Num_vertices = 0 , Num_hyperedges = 0 , Num_pins = 0 ;
7074
71- std::vector<int > vertex_weights;
75+ std::vector<int > vertex_work_weights;
76+ std::vector<int > vertex_memory_weights;
7277 std::vector<int > hyperedge_weights;
7378
7479 std::vector<std::vector<unsigned >> incident_hyperedges_to_vertex;
@@ -92,9 +97,10 @@ void Hypergraph::add_pin(unsigned vertex_idx, unsigned hyperedge_idx)
9297 }
9398}
9499
95- void Hypergraph::add_vertex (int weight )
100+ void Hypergraph::add_vertex (int work_weight, int memory_weight )
96101{
97- vertex_weights.push_back (weight);
102+ vertex_work_weights.push_back (work_weight);
103+ vertex_memory_weights.push_back (memory_weight);
98104 incident_hyperedges_to_vertex.emplace_back ();
99105 ++Num_vertices;
100106}
@@ -116,12 +122,20 @@ void Hypergraph::add_hyperedge(const std::vector<unsigned>& pins, int weight)
116122 Num_pins += static_cast <unsigned >(pins.size ());
117123}
118124
119- void Hypergraph::set_vertex_weight (unsigned vertex_idx, int weight)
125+ void Hypergraph::set_vertex_work_weight (unsigned vertex_idx, int weight)
120126{
121127 if (vertex_idx >= Num_vertices)
122128 throw std::invalid_argument (" Invalid Argument while setting vertex weight: vertex index out of range." );
123129 else
124- vertex_weights[vertex_idx] = weight;
130+ vertex_work_weights[vertex_idx] = weight;
131+ }
132+
133+ void Hypergraph::set_vertex_memory_weight (unsigned vertex_idx, int weight)
134+ {
135+ if (vertex_idx >= Num_vertices)
136+ throw std::invalid_argument (" Invalid Argument while setting vertex weight: vertex index out of range." );
137+ else
138+ vertex_memory_weights[vertex_idx] = weight;
125139}
126140
127141void Hypergraph::set_hyperedge_weight (unsigned hyperedge_idx, int weight)
@@ -132,11 +146,19 @@ void Hypergraph::set_hyperedge_weight(unsigned hyperedge_idx, int weight)
132146 hyperedge_weights[hyperedge_idx] = weight;
133147}
134148
135- int Hypergraph::compute_total_vertex_weight () const
149+ int Hypergraph::compute_total_vertex_work_weight () const
150+ {
151+ int total = 0 ;
152+ for (unsigned node = 0 ; node < Num_vertices; ++node)
153+ total += vertex_work_weights[node];
154+ return total;
155+ }
156+
157+ int Hypergraph::compute_total_vertex_memory_weight () const
136158{
137159 int total = 0 ;
138160 for (unsigned node = 0 ; node < Num_vertices; ++node)
139- total += vertex_weights [node];
161+ total += vertex_memory_weights [node];
140162 return total;
141163}
142164
@@ -146,7 +168,8 @@ void Hypergraph::clear()
146168 Num_hyperedges = 0 ;
147169 Num_pins = 0 ;
148170
149- vertex_weights.clear ();
171+ vertex_work_weights.clear ();
172+ vertex_memory_weights.clear ();
150173 hyperedge_weights.clear ();
151174 incident_hyperedges_to_vertex.clear ();
152175 vertices_in_hyperedge.clear ();
@@ -159,7 +182,8 @@ void Hypergraph::reset(unsigned num_vertices_, unsigned num_hyperedges_)
159182 Num_vertices = num_vertices_;
160183 Num_hyperedges = num_hyperedges_;
161184
162- vertex_weights.resize (num_vertices_, 1 );
185+ vertex_work_weights.resize (num_vertices_, 1 );
186+ vertex_memory_weights.resize (num_vertices_, 1 );
163187 hyperedge_weights.resize (num_hyperedges_, 1 );
164188 incident_hyperedges_to_vertex.resize (num_vertices_);
165189 vertices_in_hyperedge.resize (num_hyperedges_);
@@ -171,7 +195,8 @@ void Hypergraph::convert_from_cdag_as_dag(const Graph_t& dag)
171195 reset (static_cast <unsigned >(dag.num_vertices ()), 0 );
172196 for (const auto &node : dag.vertices ())
173197 {
174- set_vertex_weight (static_cast <unsigned >(node), static_cast <int >(dag.vertex_work_weight (node)));
198+ set_vertex_work_weight (static_cast <unsigned >(node), static_cast <int >(dag.vertex_work_weight (node)));
199+ set_vertex_memory_weight (static_cast <unsigned >(node), static_cast <int >(dag.vertex_mem_weight (node)));
175200 for (const auto &child : dag.children (node))
176201 add_hyperedge ({static_cast <unsigned >(node), static_cast <unsigned >(child)}); // TODO add edge weights if present
177202 }
@@ -183,7 +208,8 @@ void Hypergraph::convert_from_cdag_as_hyperdag(const Graph_t& dag)
183208 reset (static_cast <unsigned >(dag.num_vertices ()), 0 );
184209 for (const auto &node : dag.vertices ())
185210 {
186- set_vertex_weight (static_cast <unsigned >(node), static_cast <int >(dag.vertex_work_weight (node)));
211+ set_vertex_work_weight (static_cast <unsigned >(node), static_cast <int >(dag.vertex_work_weight (node)));
212+ set_vertex_memory_weight (static_cast <unsigned >(node), static_cast <int >(dag.vertex_mem_weight (node)));
187213 if (dag.out_degree (node) == 0 )
188214 continue ;
189215 std::vector<unsigned > new_hyperedge ({static_cast <unsigned >(node)});
0 commit comments