![]() |
STAG C++
2.0.0
Spectral Toolkit of Algorithms for Graphs
|
#include <graph.h>
An abstract class which defines methods for exploring the local neighborhood of vertices in a graph.
To maximise the performance of the local algorithms using this class, subclasses should cache the results of expensive queries. For example, if querying the neighbors of a vertex requires accessing the disk, then the result should be cached.
Public Member Functions | |
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 |
|
virtualdefault |
Destructor for the LocalGraph object.
Given a vertex v, return its weighted degree.
A self-loop of weight \(1\) contributes \(2\) to the vertex's degree.
Implemented in stag::Graph, and stag::AdjacencyListLocalGraph.
Given a vertex v, return its unweighted degree. That is, the number of neighbors of v, ignoring the edge weights.
Implemented in stag::Graph, and stag::AdjacencyListLocalGraph.
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 |
Implemented in stag::Graph, and stag::AdjacencyListLocalGraph.
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 |
Implemented in stag::Graph, and stag::AdjacencyListLocalGraph.
|
pure virtual |
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. |
Implemented in stag::Graph, and stag::AdjacencyListLocalGraph.
|
pure virtual |
Given a list of vertices, return their unweighted degrees.
vertices | a vector of ints representing the vertices to be queried. |
Implemented in stag::Graph, and stag::AdjacencyListLocalGraph.
|
pure virtual |
Given a vertex ID, returns true or false to indicate whether the vertex exists in the graph.
v | the vertex index to check |
Implemented in stag::Graph, and stag::AdjacencyListLocalGraph.