Class IOBase

Class Documentation

class sparsebase::bases::IOBase

Public Static Functions

template<typename IDType, typename NNZType, typename ValueType>
static inline format::CSR<IDType, NNZType, ValueType> *ReadMTXToCSR(std::string filename, bool convert_index_to_zero = true)

Read a matrix market file into a CSR format.

Read the matrix market file in the path filename into a CSR<IDType, NNZType, ValueType> object.

Template Parameters
  • IDType – type to represent the number of rows and columns in the object.

  • NNZType – type to represent the number of non-zeros in the object.

  • ValueType – type to represent the data inside the matrix (vertex weights in the case of a graph).

Parameters
  • filename – the path to the matrix market file.

  • convert_index_to_zero – whether to convert indices in the matrix market to zero-indexing or to read them as is and add an empty zeroth row and column.

Returns

a pointer at a CSR<IDType, NNZType, ValueType> object.

template<typename IDType, typename NNZType, typename ValueType>
static inline format::COO<IDType, NNZType, ValueType> *ReadMTXToCOO(std::string filename, bool convert_index_to_zero = true)

Read a matrix market file into a COO format.

Read the matrix market file in the path filename into a COO<IDType, NNZType, ValueType> object.

Template Parameters
  • IDType – type to represent the number of rows and columns in the object.

  • NNZType – type to represent the number of non-zeros in the object.

  • ValueType – type to represent the data inside the matrix (vertex weights in the case of a graph).

Parameters
  • filename – the path to the matrix market file.

  • convert_index_to_zero – whether to convert indices in the matrix market to zero-indexing or to read them as is and add an empty zeroth row and column.

Returns

a pointer at a COO<IDType, NNZType, ValueType> object.

template<typename IDType, typename NNZType, typename ValueType>
static inline format::Array<ValueType> *ReadMTXToArray(std::string filename, bool convert_index_to_zero = true)

Read a matrix market file into a dense array format.

Read the matrix market file in the path filename into a Array<ValueType> object. If the matrix inside the file has more than a single row or more than a single column, an exception will be thrown.

Template Parameters
  • IDType – type to represent the number of rows and columns in the object.

  • NNZType – type to represent the number of non-zeros in the object.

  • ValueType – type to represent the data inside the matrix (vertex weights in the case of a graph).

Parameters
  • filename – the path to the matrix market file.

  • convert_index_to_zero – whether to convert indices in the matrix market to zero-indexing or to read them as is and add an empty zeroth row and column.

Returns

a pointer at a Array<ValueType> object.

template<typename IDType, typename NNZType, typename ValueType>
static inline format::CSR<IDType, NNZType, ValueType> *ReadPigoMTXToCSR(std::string filename, bool weighted, bool convert_index_to_zero = true)

Read a matrix market file into a CSR format using PIGO parallel reading.

Read the matrix market file in the path filename into a CSR<IDType, NNZType, ValueType> object.

Template Parameters
  • IDType – type to represent the number of rows and columns in the object.

  • NNZType – type to represent the number of non-zeros in the object.

  • ValueType – type to represent the data inside the matrix (vertex weights in the case of a graph).

Parameters
  • filename – the path to the matrix market file.

  • convert_index_to_zero – whether to convert indices in the matrix market to zero-indexing or to read them as is and add an empty zeroth row and column.

Returns

a pointer at a CSR<IDType, NNZType, ValueType> object.

template<typename IDType, typename NNZType, typename ValueType>
static inline format::COO<IDType, NNZType, ValueType> *ReadPigoMTXToCOO(std::string filename, bool weighted, bool convert_index_to_zero = true)
template<typename IDType, typename NNZType, typename ValueType>
static inline format::CSR<IDType, NNZType, ValueType> *ReadPigoEdgeListToCSR(std::string filename, bool weighted)
template<typename IDType, typename NNZType, typename ValueType>
static inline format::COO<IDType, NNZType, ValueType> *ReadPigoEdgeListToCOO(std::string filename, bool weighted)
template<typename IDType, typename NNZType, typename ValueType>
static inline format::CSR<IDType, NNZType, ValueType> *ReadEdgeListToCSR(std::string filename, bool weighted = false, bool remove_self_edges = false, bool read_undirected = true, bool square = false)

Read an edge list file into a CSR object.

Reads an edge list file into a CSR<IDType, NNZType, ValueType> object.

Template Parameters
  • IDType – type to represent the number of rows and columns in the object.

  • NNZType – type to represent the number of non-zeros in the object.

  • ValueType – type to represent the data inside the matrix (vertex weights in the case of a graph).

Parameters
  • filename – path to the edge list file.

  • weighted – whether the edge list file contains edge weights.

  • remove_self_edges – whether self-edges should be removed.

  • read_undirected – if true, reading the edge (u,v) will also add the edge (v,u) to the object.

  • square – whether the graph is square.

Returns

A pointer at a CSR<IDType, NNZType, ValueType> object.

template<typename IDType, typename NNZType, typename ValueType>
static inline format::COO<IDType, NNZType, ValueType> *ReadEdgeListToCOO(std::string filename, bool weighted = false, bool remove_self_edges = false, bool read_undirected = true, bool square = false)

Read an edge list file into a COO object.

Reads an edge list file into a COO<IDType, NNZType, ValueType> object.

Template Parameters
  • IDType – type to represent the number of rows and columns in the object.

  • NNZType – type to represent the number of non-zeros in the object.

  • ValueType – type to represent the data inside the matrix (vertex weights in the case of a graph).

Parameters
  • filename – path to the edge list file.

  • weighted – whether the edge list file contains edge weights.

  • remove_self_edges – whether self-edges should be removed.

  • read_undirected – if true, reading the edge (u,v) will also add the edge (v,u) to the object.

  • square – whether the graph is square.

Returns

A pointer at a COO<IDType, NNZType, ValueType> object.

template<typename IDType, typename NNZType, typename ValueType>
static inline format::CSR<IDType, NNZType, ValueType> *ReadBinaryToCSR(std::string filename)

Read an SparseBase Binary file into a CSR.

Reads a SparseBase binary file into a CSR<IDType, NNZType, ValueType> object

Template Parameters
  • IDType – type to represent the number of rows and columns in the object.

  • NNZType – type to represent the number of non-zeros in the object.

  • ValueType – type to represent the data inside the matrix (vertex weights in the case of a graph).

Parameters

filename – path to the edge list file.

Returns

A pointer at a CSR<IDType, NNZType, ValueType> object.

template<typename IDType, typename NNZType, typename ValueType>
static inline format::COO<IDType, NNZType, ValueType> *ReadBinaryToCOO(std::string filename)

Read an SparseBase Binary file into a COO.

Reads a SparseBase binary file into a COO<IDType, NNZType, ValueType> object

Template Parameters
  • IDType – type to represent the number of rows and columns in the object.

  • NNZType – type to represent the number of non-zeros in the object.

  • ValueType – type to represent the data inside the matrix (vertex weights in the case of a graph).

Parameters

filename – path to the edge list file.

Returns

A pointer at a COO<IDType, NNZType, ValueType> object.

template<typename ValueType>
static inline format::Array<ValueType> *ReadBinaryToArray(std::string filename)

Read an SparseBase Binary file into a Array.

Reads a SparseBase binary file into a Array<ValueType> object

Template Parameters

ValueType – type to represent the data inside the matrix (vertex weights in the case of a graph).

Parameters

filename – path to the edge list file.

Returns

A pointer at a Array<ValueType> object.

template<typename IDType, typename NNZType, typename ValueType>
static inline void WriteCOOToBinary(format::COO<IDType, NNZType, ValueType> *coo, std::string filename)

Write a COO object to a SparseBase binary file.

Write a COO object to a SparseBase binary file.

Template Parameters
  • IDType – type to represent the number of rows and columns in the object.

  • NNZType – type to represent the number of non-zeros in the object.

  • ValueType – type to represent the data inside the matrix (vertex weights in the case of a graph).

Parameters
  • coo – a pointer at the COO<IDType, NNZType, ValueType> object to write.

  • filename – path to write the file.

template<typename IDType, typename NNZType, typename ValueType>
static inline void WriteCSRToBinary(format::CSR<IDType, NNZType, ValueType> *csr, std::string filename)

Write a CSR object to a SparseBase binary file.

Write a CSR object to a SparseBase binary file.

Template Parameters
  • IDType – type to represent the number of rows and columns in the object.

  • NNZType – type to represent the number of non-zeros in the object.

  • ValueType – type to represent the data inside the matrix (vertex weights in the case of a graph).

Parameters
  • csr – a pointer at the CSR<IDType, NNZType, ValueType> object to write.

  • filename – path to write the file.

template<typename ValueType>
static inline void WriteArrayToBinary(format::Array<ValueType> *array, std::string filename)

Write an Array object to a SparseBase binary file.

Write a Array object to a SparseBase binary file.

Template Parameters

ValueType – type to represent the data inside the matrix (vertex weights in the case of a graph).

Parameters
  • array – a pointer at the Array<ValueType> object to write.

  • filename – path to write the file.