Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
psco-2019-gp
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Florian Heinrichs
psco-2019-gp
Commits
bb3a8562
Commit
bb3a8562
authored
5 years ago
by
p-hamann
Browse files
Options
Downloads
Patches
Plain Diff
Extend partition to requirements of bnb
parent
07f7cc63
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bnb/partition.cpp
+14
-10
14 additions, 10 deletions
bnb/partition.cpp
include/gp-bnb/partition.hpp
+14
-3
14 additions, 3 deletions
include/gp-bnb/partition.hpp
with
28 additions
and
13 deletions
bnb/partition.cpp
+
14
−
10
View file @
bb3a8562
#include
<cassert>
#include
<gp-bnb/partition.hpp>
partition
::
partition
(
graph
*
g
)
:
supergraph_
(
g
)
{
...
...
@@ -12,15 +14,20 @@ partition::partition(graph* g) : supergraph_(g) {
vertices_
[
none
]
=
g
->
num_vertices
();
}
unsigned
int
partition
::
num_vertices
(
subgraph
sg
)
{
return
vertices_
[
sg
];
unsigned
int
partition
::
num_vertices_of
(
subgraph
sg
)
const
{
return
vertices_
.
at
(
sg
);
}
unsigned
int
partition
::
current_objective
()
const
{
return
current_objective_
;
}
partition
::
subgraph
partition
::
assigned_subgraph_of
(
vertex_id
v
)
const
{
return
vertex_assignments_
[
v
-
1
];
}
void
partition
::
assign_vertex
(
vertex_id
v
,
subgraph
sg
)
{
// Returns if v is already assigned to a subgraph
if
(
vertex_assignments_
[
v
-
1
]
!=
none
)
{
return
;
}
assert
(
vertex_assignments_
[
v
-
1
]
!=
none
);
// Increments current objectives
for
(
auto
const
&
target
:
supergraph_
->
get_adjacency
(
v
))
{
...
...
@@ -38,10 +45,7 @@ void partition::assign_vertex(vertex_id v, subgraph sg) {
void
partition
::
unassign_vertex
(
vertex_id
v
)
{
subgraph
sg
=
vertex_assignments_
[
v
-
1
];
// Returns if v is not assigned to a subgraph
if
(
sg
==
none
)
{
return
;
}
assert
(
sg
==
none
);
// Decrements current objectives
for
(
auto
const
&
target
:
supergraph_
->
get_adjacency
(
v
))
{
...
...
This diff is collapsed.
Click to expand it.
include/gp-bnb/partition.hpp
+
14
−
3
View file @
bb3a8562
...
...
@@ -17,12 +17,23 @@ public:
*/
partition
(
graph
*
g
);
/** @brief
R
et
urn
s the number of vertices of an element of the partition
/** @brief
G
ets the number of vertices of an element of the partition
* @param Subgraph A, B or none
* @return Number of vertices of sg
*/
unsigned
int
num_vertices_of
(
subgraph
sg
);
unsigned
int
num_vertices_of
(
subgraph
sg
)
const
;
/** @brief Gets the number of edges between subgraph A and B
* @return Objective to be minimized
*/
unsigned
int
current_objective
()
const
;
/** @brief Gets the assignment of a vertex
* @param Vertex Id
* @return Subgraph A, B or none
*/
subgraph
assigned_subgraph_of
(
vertex_id
v
)
const
;
/** @brief Assigns a vertex to a subgraph
* @param Vertex Id
* @param Subgraph A or B
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment