Graph

Defined in graph.hpp

template<class vertex_t = uint32_t, class edge_ctr_t = uint32_t, class edge_storage = vertex_t*, class edge_ctr_storage = edge_ctr_t*, bool weighted = false, class Weight = float, class WeightStorage = Weight*>
class pigo::BaseGraph : public pigo::CSR<uint32_t, uint32_t, uint32_t*, uint32_t*, false, float, float*>

Used to load graphs from disk.

This class provides a graph-specific naming on top of CSRs.

tparam vertex_t

the type to use for vertices

tparam edge_ctr_t

the type to use for an edge counter

tparam edge_storage

the storage type of the endpoints of the CSR.

tparam edge_ctr_storage

the storage type of the offsets of the CSR.

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

edge_ctr_t neighbor_start(vertex_t v)

Return the neighbors of a vertex.

Parameters

v – the vertex to find the neighbors at

Returns

an edge_ctr_t containing the neighbor start offset

edge_ctr_t neighbor_end(vertex_t v)

Return beyond the neighbors of a vertex.

Parameters

v – the vertex to end the neighbors at

Returns

an edge_ctr_t just beyond the neighbor list

inline edge_ctr_t degree(vertex_t v)

Return the number of neighbors (degree) of a vertex.

Parameters

v – the vertex to return the degree of

Returns

the number of neighbors of the vertex

inline EdgeIt<vertex_t, edge_ctr_t, edge_storage> neighbors(vertex_t v)

Return an iterator for the neighbors the vertex.

Parameters

v – the vertex to iterate over the neighbors of

Returns

an edge iterator

template<class vertex_t = uint32_t, class edge_ctr_t = uint32_t, class edge_storage = vertex_t*, class edge_ctr_storage = edge_ctr_t*, bool weighted = false, class Weight = float, class WeightStorage = Weight*>
class pigo::DiGraph

Used to load directed graphs from disk.

This class provides a graph-specific naming on top of non-symmetric matrices (Matrix).

tparam vertex_t

the type to use for vertices

tparam edge_ctr_t

the type to use for an edge counter

tparam edge_storage

the storage type of the endpoints of the CSR/CSC.

tparam edge_ctr_storage

the storage type of the offsets of the CSR/CSC.

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

template<class COOvertex_t, class COOedge_ctr_t, class COOStorage, bool COOsym, bool COOut, bool COOsl, class COOW, class COOWS>
inline DiGraph(COO<COOvertex_t, COOedge_ctr_t, COOStorage, COOsym, COOut, COOsl, weighted, COOW, COOWS> &coo)

Initialize from a COO.

This creates a DiGraph from an already-loaded COO.

This first copies the COO and transposes the copy, setting that as the in-edges. The out-edges are the original COO.

Template Parameters
  • COOvertex_t – the label for the COO format

  • COOedge_ctr_t – the ordinal for the COO format

  • COOStorage – the storage format of the COO

  • COOsym – whether the COO is symmetrized

  • COOut – whether the COO only keeps the upper triangle

  • COOsl – whether the COO removes self loops

  • COOW – the weight type of the COO

  • COOWS – the weight storage type of the COO

Parameters

coo – the COO object to load the CSR from

DiGraph(std::string fn)

Initialize from a file.

The file type will attempt to be determined automatically.

Parameters

fn – the filename to open

DiGraph(std::string fn, FileType ft)

Initialize from a file with a specific type.

Parameters
  • fn – the filename to open

  • ft – the FileType to use

DiGraph(File &f, FileType ft)

Initialize from an open file with a specific type.

Parameters
  • f – the open File

  • ft – the FileType to use

inline void free()

Free the associated memory.

inline edge_ctr_t m()

Return the number of non-zeros or edges.

inline edge_ctr_t n()

Return the number of vertices.

inline edge_ctr_t nrows()

Return the number of rows.

inline edge_ctr_t ncols()

Return the number of columns.

inline BaseGraph<vertex_t, edge_ctr_t, edge_storage, edge_ctr_storage, weighted, Weight, WeightStorage> &out()

Return the out-edges.

inline BaseGraph<vertex_t, edge_ctr_t, edge_storage, edge_ctr_storage, weighted, Weight, WeightStorage> &in()

Return the in-edges.

void save(std::string fn)

Save the loaded DiGraph as a PIGO binary file.

This saves the current DiGraph to disk

Parameters

fn – the filename to save as

Public Static Attributes

static constexpr const char *digraph_file_header = "PIGO-DiGraph-v1"

The output file header for reading/writing

template<class V, class O, class S>
class pigo::EdgeItT

An iterator type for edges.

tparam V

the vertex ID type

tparam O

the ordinal type

tparam S

the storage type for the edges

Public Functions

inline EdgeItT(S s, O pos)

Initialize the edge list iterator type.

Parameters
  • s – the storage for the edge list endpoints

  • pos – the position in the storage

template<class V, class O, class S>
class pigo::EdgeIt

An iterable edge list.

tparam V

the vertex ID type

tparam O

the ordinal type

tparam S

the storage type for the edges

param begin

the starting offset

param end

one passed the starting offset

Public Functions

inline EdgeIt(O begin, O end, S s)

Construct the edge iterator for the given offset values.

Parameters
  • begin – the starting offset

  • end – the ending offset

  • s – the storage

inline EdgeItT<V, O, S> begin()

Return the iterator start

inline EdgeItT<V, O, S> end()

Return the iterator end

type pigo::Graph
type pigo::BigGraph