Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions include/CXXGraph/CXXGraphConfig.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// the configured options and settings for CXXGraph
#define CXXGraph_VERSION_MAJOR 4
#define CXXGraph_VERSION_MINOR 1
#define CXXGraph_VERSION_PATCH 0
// the configured options and settings for CXXGraph
#define CXXGraph_VERSION_MAJOR 4
#define CXXGraph_VERSION_MINOR 1
#define CXXGraph_VERSION_PATCH 0
26 changes: 19 additions & 7 deletions include/CXXGraph/Graph/Graph_decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,20 @@ class Graph {
*/
virtual void removeNode(const std::string &nodeUserId);

/**
* \brief
* Invalidates and rebuilds the graph's core caches.
* This includes the adjacency matrix, degree matrix, and Laplacian matrix.
* Optionally, the transition matrix can also be rebuilt.
*
* \param includeTransitionMatrix
* If true, the transition matrix will be rebuilt as part of the cache update.
*
* \note Not thread-safe.
* \note Call after any structural modification of the graph.
*/
void invalidateCache(bool includeTransitionMatrix);

/**
* \brief
* Finds the given edge defined by v1 and v2 within the graph.
Expand Down Expand Up @@ -562,10 +576,9 @@ class Graph {
virtual std::shared_ptr<std::vector<Node<T>>> eulerianPath() const;

/**
* @brief Function runs the dijkstra algorithm with inverted metric for some source node and
* target node in the graph and returns the longest distance of target
* from the source (called critical path).
* Note: No Thread Safe
* @brief Function runs the dijkstra algorithm with inverted metric for some
* source node and target node in the graph and returns the longest distance
* of target from the source (called critical path). Note: No Thread Safe
*
* @param source source vertex
* @param target target vertex
Expand All @@ -574,9 +587,8 @@ class Graph {
* case if target is not reachable from source or there is error in the
* computation.
*/
virtual const DijkstraResult criticalpath_deterministic(const Node<T>& source,
const Node<T>& target) const;

virtual const DijkstraResult criticalpath_deterministic(
const Node<T> &source, const Node<T> &target) const;

/**
* @brief Function runs the dijkstra algorithm for some source node and
Expand Down
25 changes: 14 additions & 11 deletions include/CXXGraph/Graph/Graph_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ using std::make_unique;
template <typename T>
Graph<T>::Graph() {
/* Caching the adjacency matrix */
cacheAdjMatrix();
cacheDegreeMatrix();
cacheLaplacianMatrix();
cacheTransitionMatrix();
invalidateCache(true);
}

template <typename T>
Expand All @@ -48,10 +45,7 @@ Graph<T>::Graph(const T_EdgeSet<T> &edgeSet) {
this->edgeSet.insert(edgeIt);
}
/* Caching the adjacency matrix */
cacheAdjMatrix();
cacheDegreeMatrix();
cacheLaplacianMatrix();
cacheTransitionMatrix();
invalidateCache(true);
}

template <typename T>
Expand All @@ -72,9 +66,7 @@ void Graph<T>::setEdgeSet(const T_EdgeSet<T> &edgeSet) {
this->edgeSet.insert(edgeIt);
}
/* Caching the adjacency matrix */
cacheAdjMatrix();
cacheDegreeMatrix();
cacheLaplacianMatrix();
invalidateCache(false);
}

template <typename T>
Expand Down Expand Up @@ -610,6 +602,17 @@ void Graph<T>::cacheLaplacianMatrix() {
this->cachedLaplacianMatrix = laplacianMatrix;
}

template <typename T>
void Graph<T>::invalidateCache(bool includeTransitionMatrix) {
cacheAdjMatrix();
cacheDegreeMatrix();
cacheLaplacianMatrix();

if (includeTransitionMatrix) {
cacheTransitionMatrix();
}
}

template <typename T>
shared<TransitionMatrix<T>> Graph<T>::getTransitionMatrix() const {
const auto adjacencyMatrix = this->cachedAdjMatrix;
Expand Down
Loading