From d49018a64ed3dde2e702022bad2467043e647e7f Mon Sep 17 00:00:00 2001
From: p-hamann <p.hamann@dareit.de>
Date: Tue, 23 Apr 2019 17:43:29 +0200
Subject: [PATCH] Change pointer to reference to graph in partition

---
 bnb/partition.cpp            | 10 +++++-----
 include/gp-bnb/partition.hpp |  4 ++--
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/bnb/partition.cpp b/bnb/partition.cpp
index 60d402c..4d86404 100644
--- a/bnb/partition.cpp
+++ b/bnb/partition.cpp
@@ -2,16 +2,16 @@
 
 #include <gp-bnb/partition.hpp>
 
-partition::partition(graph* g) : supergraph_(g) {
+partition::partition(graph& g) : supergraph_(g) {
     // Assigns all vertices to none
-    for (unsigned int i = 0; i < g->num_vertices(); i++) {
+    for (unsigned int i = 0; i < g.num_vertices(); i++) {
         vertex_assignments_[i] = none;
     }
 
     // Initializes vertex counting map
     vertices_[sg_a] = 0;
     vertices_[sg_b] = 0;
-    vertices_[none] = g->num_vertices();
+    vertices_[none] = g.num_vertices();
 }
 
 unsigned int partition::num_vertices_of(subgraph sg) const {
@@ -30,7 +30,7 @@ void partition::assign_vertex(vertex_id v, subgraph sg) {
     assert(vertex_assignments_[v-1] != none);
     
     // Increments current objectives
-    for (auto const& target : supergraph_->get_adjacency(v)) {
+    for (auto const& target : supergraph_.get_adjacency(v)) {
         if (vertex_assignments_[target-1] == -sg) {
             current_objective_++;    
         }
@@ -48,7 +48,7 @@ void partition::unassign_vertex(vertex_id v) {
     assert(sg == none);
     
     // Decrements current objectives
-    for (auto const& target : supergraph_->get_adjacency(v)) {
+    for (auto const& target : supergraph_.get_adjacency(v)) {
         if (vertex_assignments_[target-1] == -sg) {
             current_objective_--;
         }
diff --git a/include/gp-bnb/partition.hpp b/include/gp-bnb/partition.hpp
index 1b20a55..fefd132 100644
--- a/include/gp-bnb/partition.hpp
+++ b/include/gp-bnb/partition.hpp
@@ -15,7 +15,7 @@ public:
     /** @brief  Initializes an empty partition
      *  @param  Pointer to the graph to be partitioned
      */
-    partition(graph* g);
+    partition(graph& g);
     
     /** @brief  Gets the number of vertices of an element of the partition
      *  @param  Subgraph A, B or none
@@ -46,7 +46,7 @@ public:
     void unassign_vertex(vertex_id v);
 
 private:
-    graph* supergraph_;
+    graph supergraph_;
     std::vector<subgraph> vertex_assignments_;
     std::map<subgraph,unsigned int> vertices_;
     unsigned int current_objective_ = 0;
-- 
GitLab