Skip to content

Commit c0cf7ad

Browse files
committed
Updates for performance and ease of moving to constexpr later, C++26 or using a constexpr set lib
1 parent f2543eb commit c0cf7ad

File tree

2 files changed

+14
-21
lines changed

2 files changed

+14
-21
lines changed

include/CXXGraph/Edge/DirectedEdge.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
/*** License: MPL v2.0 ***/
1818
/***********************************************************/
1919

20-
#ifndef __CXXGRAPH_DIRECTEDEDGE_H__
21-
#define __CXXGRAPH_DIRECTEDEDGE_H__
20+
#ifndef CXXGRAPH_DIRECTEDEDGE_H
21+
#define CXXGRAPH_DIRECTEDEDGE_H
2222

2323
#pragma once
2424

2525
#include "DirectedEdge_impl.hpp"
2626

27-
#endif // __CXXGRAPH_DIRECTEDEDGE_H__
27+
#endif // CXXGRAPH_DIRECTEDEDGE_H

include/CXXGraph/Graph/Graph_impl.hpp

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,28 +31,21 @@
3131
namespace CXXGraph {
3232

3333
using std::make_shared;
34-
using std::make_unique;
3534

3635
template <typename T>
37-
Graph<T>::Graph() {
38-
/* Caching the adjacency matrix */
39-
cacheAdjMatrix();
40-
cacheDegreeMatrix();
41-
cacheLaplacianMatrix();
42-
cacheTransitionMatrix();
43-
}
36+
Graph<T>::Graph()
37+
: cachedAdjMatrix(Graph<T>::getAdjMatrix()),
38+
cachedDegreeMatrix(Graph<T>::getDegreeMatrix()),
39+
cachedLaplacianMatrix(Graph<T>::getLaplacianMatrix()),
40+
cachedTransitionMatrix(Graph<T>::getTransitionMatrix()) {}
4441

4542
template <typename T>
46-
Graph<T>::Graph(const T_EdgeSet<T> &edgeSet) {
47-
for (auto edgeIt : edgeSet) {
48-
this->edgeSet.insert(edgeIt);
49-
}
50-
/* Caching the adjacency matrix */
51-
cacheAdjMatrix();
52-
cacheDegreeMatrix();
53-
cacheLaplacianMatrix();
54-
cacheTransitionMatrix();
55-
}
43+
Graph<T>::Graph(const T_EdgeSet<T> &edgeSetToCopy)
44+
: edgeSet(edgeSetToCopy),
45+
cachedAdjMatrix(Graph<T>::getAdjMatrix()),
46+
cachedDegreeMatrix(Graph<T>::getDegreeMatrix()),
47+
cachedLaplacianMatrix(Graph<T>::getLaplacianMatrix()),
48+
cachedTransitionMatrix(Graph<T>::getTransitionMatrix()) {}
5649

5750
template <typename T>
5851
const T_EdgeSet<T> &Graph<T>::getEdgeSet() const {

0 commit comments

Comments
 (0)