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
Julian Scherzer
psco-2019-gp
Commits
655ca6bd
Commit
655ca6bd
authored
5 years ago
by
p-hamann
Browse files
Options
Downloads
Patches
Plain Diff
Update member identifiers
parent
4dacbf1e
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
bnb/graph.cpp
+3
-3
3 additions, 3 deletions
bnb/graph.cpp
bnb/partition.cpp
+22
-22
22 additions, 22 deletions
bnb/partition.cpp
include/gp-bnb/graph.hpp
+2
-2
2 additions, 2 deletions
include/gp-bnb/graph.hpp
include/gp-bnb/partition.hpp
+4
-4
4 additions, 4 deletions
include/gp-bnb/partition.hpp
with
31 additions
and
31 deletions
bnb/graph.cpp
+
3
−
3
View file @
655ca6bd
#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
];
}
This diff is collapsed.
Click to expand it.
bnb/partition.cpp
+
22
−
22
View file @
655ca6bd
#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 edg
es
for
(
auto
const
&
target
:
supergraph
->
get_adjacency
(
v
))
{
if
(
vertex_assignments
[
target
-
1
]
==
-
sg
)
{
outgoing_edges
++
;
// Increments
current objectiv
es
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 edg
es
for
(
auto
const
&
target
:
supergraph
->
get_adjacency
(
v
))
{
if
(
vertex_assignments
[
target
-
1
]
==
-
sg
)
{
outgoing_edges
--
;
// Decrements
current objectiv
es
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
]
++
;
}
This diff is collapsed.
Click to expand it.
include/gp-bnb/graph.hpp
+
2
−
2
View file @
655ca6bd
...
...
@@ -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
This diff is collapsed.
Click to expand it.
include/gp-bnb/partition.hpp
+
4
−
4
View file @
655ca6bd
...
...
@@ -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
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