COO¶
Defined in coo.hpp
-
template<class Label = uint32_t, class Ordinal = Label, class Storage = Label*, bool symmetric = false, bool keep_upper_triangle_only = false, bool remove_self_loops = false, bool weighted = false, class Weight = float, class WeightStorage = Weight*>
class pigo::COO¶ Holds coordinate-addressed matrices or graphs.
A COO is a fundamental object in PIGO. It is able to read a variety of input formats (e.g., matrix market) and exposes the read data as an edge list.
The edge list is stored as multiple arrays, one for the x elements and one for the y elements (e.g., src and dst in graphs.) The storage method is a template parameter.
- tparam Label
the label data type. This type needs to be able to support the largest value read inside of the COO. In a graph this is the largest vertex ID.
- tparam Ordinal
the ordinal data type. This type needs to support large enough values to hold the number of entries or rows in the COO. It defaults to the same type as the label type.
- tparam Storage
the storage type of the COO. This can either be vector (std::vector<Label>), a pointer (Label*), or a shared_ptr (std::shared_ptr<Label>).
- tparam symmetric
Ensure that the COO is symmetric, that is ensure that for every coordinate there is a corresponding symmetric coordinate with the same value. If true, this will always be the case. If false, any symmetry will be based on whether the input is.
- tparam keep_upper_triangle_only
Only keep values that are in the upper triangle (if the coordinate is (x,y,val), only keep it in the coo if x <= y) If this is used with symmetric, then the COO will first symmetrize and then remove any value out of the upper triangle. If this is used without symmetric, then any edges with (y > x) will not be included in the COO.
- tparam remove_self_loops
remove any self loops. If set to true, this will detect and remove any self loops (if the coordinate is (x,y,val) and (x==y), the entry will not be included in the COO.
- tparam weighted
if true, support and use weights
- tparam Weight
the weight data type.
- tparam WeightStorage
the storage type for the weights. This can be a raw pointer (Weight*), a std::vector (std::vector<Weight>), or a std::shared_ptr<Weight>.
Public Functions
-
COO(std::string fn)¶
Initialize a COO from a file.
The file type will attempt to be determined automatically.
- Parameters
fn – the filename to open
-
COO(std::string fn, FileType ft)¶
Initialize a COO from a file with a specific type.
- Parameters
fn – the filename to open
ft – the FileType to use
-
COO(File &f, FileType ft)¶
Initialize a COO from an open File with a specific type.
- Parameters
f – the File to use
ft – the FileType to use
-
template<class CL, class CO, typename LabelStorage, typename OrdinalStorage, class CW, class CWS>
COO(CSR<CL, CO, LabelStorage, OrdinalStorage, weighted, CW, CWS> &csr)¶ Initialize from a CSR.
- Parameters
csr – the CSR to convert from
-
inline COO(Label n, Label nrows, Label ncols, Ordinal m)¶
Provide space for copying in existing, out-of-band data.
-
inline WeightStorage &w()¶
Retrieve the weight array.
- Returns
the weight array in the format WeightStorage
-
inline Label n() const¶
Retrieves the number of labels the COO contains.
Note: This will include any zero entry-labels. So, the count is the largest seen label+1.
- Returns
the number of labels
-
inline Label ncols() const¶
Retrieves the number of columns in the COO.
- Returns
the number of columns
-
inline void free()¶
Utility to free consumed memory.
As an IO library, PIGO generally leaves memory cleanup to downstream applications and does not always deallocate in destructors. In some cases it is helpful for PIGO to cleanup directly and then this can be used.
Public Static Attributes
-
static constexpr const char *coo_file_header = "PIGO-COO-v1"¶
The output file header for reading/writing
-
type pigo::WCOO¶
-
type pigo::WCOOPtr¶