diff --git a/system/graph/TupleGraph.cpp b/system/graph/TupleGraph.cpp index b94316696..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 ) { +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."; @@ -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; 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;