Add GraphBase::getDegree()
This commit is contained in:
@@ -23,6 +23,7 @@ class GraphBase
|
||||
public:
|
||||
size_t getNVertices() const;
|
||||
size_t getNEdges() const;
|
||||
size_t getDegree(const int vertex) const;
|
||||
bool areAdjacent(const int vertex1, const int vertex2) const;
|
||||
|
||||
struct Incidence
|
||||
@@ -51,7 +52,7 @@ class GraphBase
|
||||
{
|
||||
if (vertex >= 0 && vertex < graph_->getNVertices())
|
||||
{
|
||||
setIncidence(graph_->firstVertexIncidences[vertex]);
|
||||
setIncidence(graph_->vertexIncidenceHeaders[vertex].first);
|
||||
}
|
||||
};
|
||||
NeighborIterator& operator++()
|
||||
@@ -99,7 +100,8 @@ class GraphBase
|
||||
NeighborIterator end() const;
|
||||
|
||||
protected:
|
||||
std::vector<int> firstVertexIncidences{};
|
||||
// First is the index of the first incidence, second is the number of incidences (the length of the list).
|
||||
std::vector<std::pair<int, size_t>> vertexIncidenceHeaders{};
|
||||
std::vector<int> nextIncidences{};
|
||||
std::vector<int> incidenceVertices{};
|
||||
int addVertexInternal();
|
||||
|
||||
Reference in New Issue
Block a user