Skip to content

Commit

Permalink
Updates for performance and ease of moving to constexpr later, C++26 …
Browse files Browse the repository at this point in the history
…or using a constexpr set lib
  • Loading branch information
OlekRaymond committed Jan 6, 2025
1 parent f2543eb commit c0cf7ad
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 21 deletions.
6 changes: 3 additions & 3 deletions include/CXXGraph/Edge/DirectedEdge.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
/*** License: MPL v2.0 ***/
/***********************************************************/

#ifndef __CXXGRAPH_DIRECTEDEDGE_H__
#define __CXXGRAPH_DIRECTEDEDGE_H__
#ifndef CXXGRAPH_DIRECTEDEDGE_H
#define CXXGRAPH_DIRECTEDEDGE_H

#pragma once

#include "DirectedEdge_impl.hpp"

#endif // __CXXGRAPH_DIRECTEDEDGE_H__
#endif // CXXGRAPH_DIRECTEDEDGE_H
29 changes: 11 additions & 18 deletions include/CXXGraph/Graph/Graph_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,21 @@
namespace CXXGraph {

using std::make_shared;
using std::make_unique;

template <typename T>
Graph<T>::Graph() {
/* Caching the adjacency matrix */
cacheAdjMatrix();
cacheDegreeMatrix();
cacheLaplacianMatrix();
cacheTransitionMatrix();
}
Graph<T>::Graph()
: cachedAdjMatrix(Graph<T>::getAdjMatrix()),
cachedDegreeMatrix(Graph<T>::getDegreeMatrix()),
cachedLaplacianMatrix(Graph<T>::getLaplacianMatrix()),
cachedTransitionMatrix(Graph<T>::getTransitionMatrix()) {}

template <typename T>
Graph<T>::Graph(const T_EdgeSet<T> &edgeSet) {
for (auto edgeIt : edgeSet) {
this->edgeSet.insert(edgeIt);
}
/* Caching the adjacency matrix */
cacheAdjMatrix();
cacheDegreeMatrix();
cacheLaplacianMatrix();
cacheTransitionMatrix();
}
Graph<T>::Graph(const T_EdgeSet<T> &edgeSetToCopy)
: edgeSet(edgeSetToCopy),
cachedAdjMatrix(Graph<T>::getAdjMatrix()),
cachedDegreeMatrix(Graph<T>::getDegreeMatrix()),
cachedLaplacianMatrix(Graph<T>::getLaplacianMatrix()),
cachedTransitionMatrix(Graph<T>::getTransitionMatrix()) {}

template <typename T>
const T_EdgeSet<T> &Graph<T>::getEdgeSet() const {
Expand Down

0 comments on commit c0cf7ad

Please sign in to comment.