From 655ca6bd891e480d65c142a1c9fdbc13373939c4 Mon Sep 17 00:00:00 2001 From: p-hamann <p.hamann@dareit.de> Date: Tue, 23 Apr 2019 11:28:38 +0200 Subject: [PATCH] Update member identifiers --- bnb/graph.cpp | 6 ++--- bnb/partition.cpp | 44 ++++++++++++++++++------------------ include/gp-bnb/graph.hpp | 4 ++-- include/gp-bnb/partition.hpp | 8 +++---- 4 files changed, 31 insertions(+), 31 deletions(-) diff --git a/bnb/graph.cpp b/bnb/graph.cpp index c9fe037..314bbdb 100644 --- a/bnb/graph.cpp +++ b/bnb/graph.cpp @@ -1,12 +1,12 @@ #include <gp-bnb/graph.hpp> -graph::graph(std::vector<std::vector<unsigned int>> a) : vertices(a.size()), adjacency_list(a) { +graph::graph(std::vector<std::vector<unsigned int>> a) : vertices_(a.size()), adjacency_list_(a) { } unsigned int graph::num_vertices() const { - return vertices; + return vertices_; } std::vector<unsigned int> graph::get_adjacency(vertex_id v) const { - return adjacency_list[v-1]; + return adjacency_list_[v-1]; } diff --git a/bnb/partition.cpp b/bnb/partition.cpp index 0e57911..30547ca 100644 --- a/bnb/partition.cpp +++ b/bnb/partition.cpp @@ -1,51 +1,51 @@ #include <gp-bnb/partition.hpp> -partition::partition(graph* g) : supergraph(g), outgoing_edges(0) { +partition::partition(graph* g) : supergraph_(g) { // Assigns all vertices to none for (unsigned int i = 0; i < g->num_vertices(); i++) { - vertex_assignments[i] = none; + vertex_assignments_[i] = none; } // Initializes vertex counting map - vertices[sg_a] = 0; - vertices[sg_b] = 0; - vertices[none] = g->num_vertices(); + vertices_[sg_a] = 0; + vertices_[sg_b] = 0; + vertices_[none] = g->num_vertices(); } unsigned int partition::num_vertices(subgraph sg) { - return vertices[sg]; + return vertices_[sg]; } void partition::assign_vertex(vertex_id v, subgraph sg) { // Returns if v is already assigned to a subgraph - if (vertex_assignments[v-1] != none) { + if (vertex_assignments_[v-1] != none) { return; } - // Increments outgoing edges - for (auto const& target : supergraph->get_adjacency(v)) { - if (vertex_assignments[target-1] == -sg) { - outgoing_edges++; + // Increments current objectives + for (auto const& target : supergraph_->get_adjacency(v)) { + if (vertex_assignments_[target-1] == -sg) { + current_objective_++; } } // Assigns vertex to subgraph - vertex_assignments[v-1] = sg; - vertices[sg]++; - vertices[none]--; + vertex_assignments_[v-1] = sg; + vertices_[sg]++; + vertices_[none]--; } void partition::unassign_vertex(vertex_id v) { - subgraph sg = vertex_assignments[v-1]; + subgraph sg = vertex_assignments_[v-1]; // Returns if v is not assigned to a subgraph if (sg == none) { return; } - // Decrements outgoing edges - for (auto const& target : supergraph->get_adjacency(v)) { - if (vertex_assignments[target-1] == -sg) { - outgoing_edges--; + // Decrements current objectives + for (auto const& target : supergraph_->get_adjacency(v)) { + if (vertex_assignments_[target-1] == -sg) { + current_objective_--; } } // Reverts assignment to subgraph - vertex_assignments[v-1] = none; - vertices[sg]--; - vertices[none]++; + vertex_assignments_[v-1] = none; + vertices_[sg]--; + vertices_[none]++; } diff --git a/include/gp-bnb/graph.hpp b/include/gp-bnb/graph.hpp index df0fdc4..d4eb1ff 100644 --- a/include/gp-bnb/graph.hpp +++ b/include/gp-bnb/graph.hpp @@ -23,8 +23,8 @@ public: std::vector<unsigned int> get_adjacency(vertex_id v) const; private: - unsigned int vertices; - std::vector<std::vector<unsigned int>> adjacency_list; + unsigned int vertices_; + std::vector<std::vector<unsigned int>> adjacency_list_; }; #endif diff --git a/include/gp-bnb/partition.hpp b/include/gp-bnb/partition.hpp index 793b907..ec9ef73 100644 --- a/include/gp-bnb/partition.hpp +++ b/include/gp-bnb/partition.hpp @@ -31,10 +31,10 @@ public: void unassign_vertex(vertex_id v); private: - graph* supergraph; - std::vector<subgraph> vertex_assignments; - std::map<subgraph,unsigned int> vertices; - unsigned int outgoing_edges; + graph* supergraph_; + std::vector<subgraph> vertex_assignments_; + std::map<subgraph,unsigned int> vertices_; + unsigned int current_objective_ = 0; }; #endif -- GitLab