-
Notifications
You must be signed in to change notification settings - Fork 224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow single % and integer weights with MatrixMarketReader #997
Allow single % and integer weights with MatrixMarketReader #997
Conversation
e203ce4
to
91b40fd
Compare
0ff0224
to
3ebfa66
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also update the readme for inputfiles -> https://github.com/networkit/networkit/blob/master/input/README.md
.
3ebfa66
to
9e7e6ab
Compare
9e7e6ab
to
8688b2a
Compare
8688b2a
to
0b81ccf
Compare
faa59dc
to
dff2af7
Compare
if (data == "integer") | ||
WARN( | ||
"Weights in NetworKit are stored as double precision floating point number while the given file uses integer weights.\ | ||
This means that weights bigger than 4.5e15 the weights will be recorded imprecisely."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This means that weights bigger than 4.5e15 the weights will be recorded imprecisely."); | |
This means that weights bigger than 4.5e15 will be recorded imprecisely."); |
9550769
to
5e73abe
Compare
#include <networkit/io/MatrixMarketReader.hpp> | ||
|
||
namespace NetworKit { | ||
|
||
namespace { | ||
static constexpr char COMMENT_CHAR = '%'; | ||
static const std::string MAGIC = "%%matrixmarket"; | ||
static constexpr std::string MAGIC1 = "%matrixmarket"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess thats clear, but with C++ 17 constexpr
is not supported for std::string
(so we should use static const
here).
5e73abe
to
72baab6
Compare
72baab6
to
9b2a8ff
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
First, the Matrix Market Format allows for both either a single or double
%
in the first line(https://networkrepository.com/mtx-matrix-market-format.html) so I fixed it in our reader.Also currently we don't accept integer weights but integer weights and doubles would only not be able to match up for numbers larger than 2^52. Since most weights are smaller than that I think it is better if we accept the weights and just display a warning that for weights larger than 4.5*10^15 the stored weights will not match the given weights perfectly as otherwise, we're just causing an annoyance of having to go back and edit the files to say "real" instead of
integer
.Lastly, I added tests for the MatrixmMarketRead as there were none.