![]() |
STAG C++
2.0.0
Spectral Toolkit of Algorithms for Graphs
|
#include <graph.h>
A local graph backed by an adjacency list file on disk.
The graph is loaded into memory in a local way only. That is, an adjacency list data structure is constructed in memory as node neighbours are queried. If a node is not found in the cached adjacency list, then the neighbours of the node are queried from the adjacency list on disk. This allows for local algorithms to be executed on very large graphs stored on disk without loading the whole graph into memory.
See Graph File Formats for more information about the adjacency list file format.
Public Member Functions | |
AdjacencyListLocalGraph (const std::string &filename) | |
StagReal | degree (StagInt v) override |
StagInt | degree_unweighted (StagInt v) override |
std::vector< edge > | neighbors (StagInt v) override |
std::vector< StagInt > | neighbors_unweighted (StagInt v) override |
std::vector< StagReal > | degrees (std::vector< StagInt > vertices) override |
std::vector< StagInt > | degrees_unweighted (std::vector< StagInt > vertices) override |
bool | vertex_exists (StagInt v) override |
![]() | |
virtual StagReal | degree (StagInt v)=0 |
virtual StagInt | degree_unweighted (StagInt v)=0 |
virtual std::vector< edge > | neighbors (StagInt v)=0 |
virtual std::vector< StagInt > | neighbors_unweighted (StagInt v)=0 |
virtual std::vector< StagReal > | degrees (std::vector< StagInt > vertices)=0 |
virtual std::vector< StagInt > | degrees_unweighted (std::vector< StagInt > vertices)=0 |
virtual bool | vertex_exists (StagInt v)=0 |
virtual | ~LocalGraph ()=default |
stag::AdjacencyListLocalGraph::AdjacencyListLocalGraph | ( | const std::string & | filename | ) |
Construct a local graph backed by an adjacency list file.
The adjacency list file must not be modified externally while it is in use by this object.
filename | the name of the adjacencylist file which defines the graph |
Given a vertex v, return its weighted degree.
A self-loop of weight \(1\) contributes \(2\) to the vertex's degree.
Implements stag::LocalGraph.
Given a vertex v, return its unweighted degree. That is, the number of neighbors of v, ignoring the edge weights.
Implements stag::LocalGraph.
Given a vertex v, return a vector of edges representing the neighborhood of v.
The returned edges will all have the ordering (v, x) such that edge.v = v.
v | an int representing some vertex in the graph |
Implements stag::LocalGraph.
|
overridevirtual |
Given a vertex v, return a vector containing the neighbors of v.
The weights of edges to the neighbors are not returned by this method.
v | an int representing some vertex in the graph |
Implements stag::LocalGraph.
|
overridevirtual |
Given a list of vertices, return the degrees of each vertex in the list.
Providing a method for computing the degrees 'in bulk' increases the efficiency of algorithms on graphs which are not stored directly in memory.
vertices | a vector of ints representing the vertices to be queried. |
Implements stag::LocalGraph.
|
overridevirtual |
Given a list of vertices, return their unweighted degrees.
vertices | a vector of ints representing the vertices to be queried. |
Implements stag::LocalGraph.
|
overridevirtual |
Given a vertex ID, returns true or false to indicate whether the vertex exists in the graph.
v | the vertex index to check |
Implements stag::LocalGraph.