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
b9ddda3a
Commit
b9ddda3a
authored
5 years ago
by
Lukas Garbas
Browse files
Options
Downloads
Patches
Plain Diff
Changed code style
parent
51ebb0db
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
bnb/main.cpp
+2
-2
2 additions, 2 deletions
bnb/main.cpp
bnb/metis_reader.cpp
+54
-0
54 additions, 0 deletions
bnb/metis_reader.cpp
include/gp-bnb/metis_reader.hpp
+19
-0
19 additions, 0 deletions
include/gp-bnb/metis_reader.hpp
meson.build
+2
-0
2 additions, 0 deletions
meson.build
with
77 additions
and
2 deletions
bnb/main.cpp
+
2
−
2
View file @
b9ddda3a
...
@@ -4,13 +4,13 @@
...
@@ -4,13 +4,13 @@
#include
<gp-bnb/bnb.hpp>
#include
<gp-bnb/bnb.hpp>
#include
<gp-bnb/graph.hpp>
#include
<gp-bnb/graph.hpp>
#include
<gp-bnb/partition.hpp>
#include
<gp-bnb/partition.hpp>
#include
<gp-bnb/
M
etis
R
eader.hpp>
#include
<gp-bnb/
m
etis
_r
eader.hpp>
int
main
()
{
int
main
()
{
// MetisReader example
// MetisReader example
std
::
string
graphFile
=
"../test/inputs/delaunay_n10.graph"
;
std
::
string
graphFile
=
"../test/inputs/delaunay_n10.graph"
;
auto
g
=
M
etis
R
eader
().
read
(
graphFile
);
auto
g
=
m
etis
_r
eader
().
read
(
graphFile
);
std
::
cout
<<
"Number of nodes: "
<<
g
.
num_vertices
()
<<
std
::
endl
;
std
::
cout
<<
"Number of nodes: "
<<
g
.
num_vertices
()
<<
std
::
endl
;
}
}
...
...
This diff is collapsed.
Click to expand it.
bnb/metis_reader.cpp
0 → 100644
+
54
−
0
View file @
b9ddda3a
#include
<gp-bnb/metis_reader.hpp>
#include
<stdexcept>
std
::
vector
<
unsigned
int
>
parse_line
(
std
::
string
&
line
)
{
std
::
vector
<
unsigned
int
>
adjacencies
;
std
::
stringstream
iss
(
line
);
int
node
;
while
(
iss
>>
node
)
{
adjacencies
.
push_back
(
node
);
}
return
adjacencies
;
}
graph
metis_reader
::
read
(
std
::
string
&
path
)
{
std
::
ifstream
graph_file
(
path
);
std
::
pair
<
int
,
int
>
header
;
std
::
vector
<
std
::
vector
<
unsigned
int
>>
adjacencies
;
int
edge_counter
=
0
;
std
::
string
line
=
""
;
if
(
std
::
getline
(
graph_file
,
line
))
{
// ignore comment lines
while
(
line
[
0
]
==
'%'
)
std
::
getline
(
graph_file
,
line
);
// read the header line
std
::
vector
<
unsigned
int
>
first_line
=
parse_line
(
line
);
header
=
std
::
make_pair
(
first_line
[
0
],
first_line
[
1
]);
adjacencies
.
reserve
(
header
.
first
);
std
::
cout
<<
"Reading graph in Metis format "
;
std
::
cout
<<
"(n = "
<<
header
.
first
<<
", m = "
<<
header
.
second
<<
")"
<<
std
::
endl
;
while
(
getline
(
graph_file
,
line
))
{
// ignore comment lines after the header
if
(
line
[
0
]
!=
'%'
)
{
adjacencies
.
push_back
(
parse_line
(
line
));
edge_counter
+=
adjacencies
.
back
().
size
();
}
}
}
if
(
edge_counter
/
2
!=
header
.
second
)
puts
(
"Reader Error: incorrect number of edges"
);
if
(
adjacencies
.
size
()
!=
(
unsigned
int
)
header
.
first
)
puts
(
"Reader Error: incorrect number of nodes"
);
graph
g
=
graph
(
adjacencies
);
return
g
;
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
include/gp-bnb/metis_reader.hpp
0 → 100644
+
19
−
0
View file @
b9ddda3a
#include
<fstream>
#include
<sstream>
#include
<iostream>
#include
<string>
#include
<gp-bnb/graph.hpp>
#ifndef METISREADER_H_
#define METISREADER_H_
/** Reader for the METIS file format **/
class
metis_reader
{
public:
metis_reader
()
=
default
;
graph
read
(
std
::
string
&
path
);
};
#endif
\ No newline at end of file
This diff is collapsed.
Click to expand it.
meson.build
+
2
−
0
View file @
b9ddda3a
...
@@ -11,6 +11,8 @@ executable('gp-bnb',
...
@@ -11,6 +11,8 @@ executable('gp-bnb',
'bnb/main.cpp'
,
'bnb/main.cpp'
,
'bnb/graph.cpp'
,
'bnb/graph.cpp'
,
'bnb/partition.cpp'
,
'bnb/partition.cpp'
,
'bnb/metis_reader.cpp'
,
'bnb/bnb.cpp'
,
include_directories
:
inc
)
include_directories
:
inc
)
...
...
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