Skip to content
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

Merged

Conversation

Relux-the-Relux
Copy link

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.

@Relux-the-Relux Relux-the-Relux changed the title Allow single % and integer weightswith MatrixMarketReader Allow single % and integer weights with MatrixMarketReader Oct 4, 2022
networkit/cpp/io/MatrixMarketReader.cpp Outdated Show resolved Hide resolved
networkit/cpp/io/test/IOGTest.cpp Outdated Show resolved Hide resolved
Copy link
Member

@fabratu fabratu left a 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.

@Relux-the-Relux Relux-the-Relux force-pushed the feature/improbe-matrix-reader branch 3 times, most recently from faa59dc to dff2af7 Compare November 4, 2022 01:36
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.");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.");

#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";
Copy link
Member

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).

Copy link
Member

@fabratu fabratu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@angriman angriman merged commit 1492ae7 into networkit:master Nov 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants