Skip to content

Commit

Permalink
small changes
Browse files Browse the repository at this point in the history
  • Loading branch information
wrcorcoran committed Sep 26, 2024
1 parent fd81892 commit d28c527
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 18 deletions.
5 changes: 2 additions & 3 deletions include/CXXGraph/Graph/Algorithm/Pow_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,16 @@ std::vector<std::vector<T>> matMult(std::vector<std::vector<T>> &a,
template <typename T>
std::vector<std::vector<T>> exponentiation(std::vector<std::vector<T>> &mat,
unsigned int k) {
// typechecking
static_assert(std::is_arithmetic<T>::value,
"Type T must be either unsigned long long or double");
"Type T must be any artithmetic type");

int n = static_cast<int>(mat.size());
std::vector<std::vector<T>> res(n, std::vector<T>(n, 0));

// build identity matrix
for (int i = 0; i < n; i++) res[i][i] = 1;

// fast exponentation!
// fast exponentiation!
while (k) {
if (k & 1) res = matMult(res, mat);
mat = matMult(mat, mat);
Expand Down
15 changes: 0 additions & 15 deletions test/PowTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,6 @@ TEST(PowAdjTest, triangle) {

auto res = matrixPow(graph.getAdjMatrix(), 5);

std::cout << "HERE" << std::endl;

for (const auto &[node, edges] : *graph.getAdjMatrix()) {
for (const auto &e : edges) {
const auto edge = e.second->getNodePair();
const auto firstId = edge.first->getUserId();
const auto secondId = edge.second->getUserId();

std::cout << firstId << " " << secondId << std::endl;
}
}
for (const auto &[nodes, value] : res.result) {
std::cout << value << std::endl;
}

ASSERT_TRUE(res.success);
ASSERT_TRUE(res.result[std::make_pair("a", "a")] == 10);
ASSERT_TRUE(res.result[std::make_pair("b", "b")] == 10);
Expand Down

0 comments on commit d28c527

Please sign in to comment.