From 1156fd2d6057931e14e9586019b25a5bd3cffef9 Mon Sep 17 00:00:00 2001 From: Tristan Konolige Date: Tue, 8 Dec 2015 23:24:11 -0700 Subject: [PATCH 1/2] Matrix market files use 1-indexed coordinate entries --- system/graph/TupleGraph.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/system/graph/TupleGraph.cpp b/system/graph/TupleGraph.cpp index b94316696..c614a5832 100644 --- a/system/graph/TupleGraph.cpp +++ b/system/graph/TupleGraph.cpp @@ -292,7 +292,7 @@ TupleGraph TupleGraph::load_tsv( std::string path ) { } /// Matrix Market format loader -TupleGraph TupleGraph::load_mm( std::string path ) { +TupleGraph TupleGraph::load_mm( std::string path, bool one_indexed = true ) { // make sure file exists CHECK( fs::exists( path ) ) << "File not found."; CHECK( fs::is_regular_file( path ) ) << "File is not a regular file."; @@ -442,8 +442,10 @@ TupleGraph TupleGraph::load_mm( std::string path ) { std::getline( infile, str ); } else { infile >> v0; + if(one_indexed) v0--; if( !infile.good() ) break; infile >> v1; + if(one_indexed) v1--; if( header_info.field_double ) { double d; infile >> d; From 1f8dd5f771a55bdef07b113ff2fd445e277b0e5c Mon Sep 17 00:00:00 2001 From: Tristan Konolige Date: Tue, 8 Dec 2015 23:35:37 -0700 Subject: [PATCH 2/2] forgot the header --- system/graph/TupleGraph.cpp | 2 +- system/graph/TupleGraph.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/system/graph/TupleGraph.cpp b/system/graph/TupleGraph.cpp index c614a5832..4c2f1cf08 100644 --- a/system/graph/TupleGraph.cpp +++ b/system/graph/TupleGraph.cpp @@ -292,7 +292,7 @@ TupleGraph TupleGraph::load_tsv( std::string path ) { } /// Matrix Market format loader -TupleGraph TupleGraph::load_mm( std::string path, bool one_indexed = true ) { +TupleGraph TupleGraph::load_mm( std::string path, bool one_indexed ) { // make sure file exists CHECK( fs::exists( path ) ) << "File not found."; CHECK( fs::is_regular_file( path ) ) << "File is not a regular file."; diff --git a/system/graph/TupleGraph.hpp b/system/graph/TupleGraph.hpp index 4793cc4bf..8d10965dd 100644 --- a/system/graph/TupleGraph.hpp +++ b/system/graph/TupleGraph.hpp @@ -53,7 +53,7 @@ namespace Grappa { void save_generic( std::string, void (*f)( const char *, Edge*, Edge*) ); static TupleGraph load_tsv( std::string path ); - static TupleGraph load_mm( std::string path ); + static TupleGraph load_mm( std::string path, bool one_indexed = true ); public: GlobalAddress edges;