Skip to content

Commit

Permalink
Update CMakeLists.txt
Browse files Browse the repository at this point in the history
Took 16 seconds
  • Loading branch information
flankedgonerogue committed Dec 29, 2023
1 parent 4e978f1 commit d3ac08e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 81 deletions.
9 changes: 6 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
cmake_minimum_required(VERSION 3.27)
project(Project)
project(Mining-FIs-Using-CLM VERSION 1.0 LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 20)

add_executable(Project main.cpp
set(CMAKE_CXX_FLAGS_RELEASE "-Oz -DNDEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")

add_executable(clm-miner main.cpp
src/Graph.cpp
include/Graph.h)
include/Graph.hpp)
2 changes: 1 addition & 1 deletion main.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <fstream>
#include <iostream>

#include "include/Graph.h"
#include "include\Graph.hpp"

int main(int argc, char **argv)
{
Expand Down
84 changes: 7 additions & 77 deletions src/Graph.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "../include/Graph.h"
#include "..\include\Graph.hpp"

// PRIVATE FUNCTIONS

Expand Down Expand Up @@ -36,7 +36,7 @@ int Graph::mapNodeToPosition(const char node) const noexcept
int i = 0;
for (auto it = nodes.cbegin(); it != nodes.cend(); ++i, ++it)
{
if (node == it->first)
if (node == it->label)
{
return i;
}
Expand All @@ -45,72 +45,6 @@ int Graph::mapNodeToPosition(const char node) const noexcept
return -1;
}

nlohmann::json Graph::toJSONObject() const noexcept
{
nlohmann::json json;

json["transactions"] = transactions;

std::vector<nlohmann::json> nodesJSON;
for (const auto &[node, occurrence] : nodes)
{
nlohmann::json nodeJSON;

nodeJSON["node"] = std::string(1, node);
nodeJSON["occurrence"] = occurrence;

nodesJSON.push_back(nodeJSON);
}
json["nodes"] = nodesJSON;

std::vector<nlohmann::json> edgesJSON;
for (const auto &[fromNode, toNode, extraNodes, weight] : rawEdges)
{
nlohmann::json edgeJSON;

edgeJSON["fromNode"] = std::string(1, fromNode);
edgeJSON["toNode"] = std::string(1, toNode);

std::list<std::string> extraNodesStr;
for (const auto &node : extraNodes)
{
extraNodesStr.emplace_back(1, node);
}

edgeJSON["extraNodes"] = extraNodesStr;
edgeJSON["weight"] = weight;

edgesJSON.push_back(edgeJSON);
}
json["edges"] = edgesJSON;

nlohmann::json rowsCLMJSON;
std::vector<std::string> headers;
auto it = nodes.cbegin();
for (int i = 0; i < getNodesCount(); i++)
{
headers.emplace_back(1, it->first);

for (const auto &key : nodes | std::views::keys)
{
headers.emplace_back(1, key);
}

++it;
}
rowsCLMJSON["header"] = headers;

it = nodes.cbegin();
for (const auto &row : CLM)
{
rowsCLMJSON[std::string(1, it->first)] = row;
++it;
}
json["CLM"] = rowsCLMJSON;

return json;
}


// PUBLIC FUNCTIONS

Expand Down Expand Up @@ -172,7 +106,7 @@ void Graph::processTransaction(const std::string &str)
}

// Save the history
jsonHistory.push_back(toJSONObject());
jsonHistory.emplace_back(*this);
}

void Graph::processCLM()
Expand Down Expand Up @@ -224,10 +158,6 @@ void Graph::processCLM()
}
}

std::string Graph::getJSONHistoryAsJSON() const noexcept { return nlohmann::json(jsonHistory).dump(0); }

std::string Graph::toJSON(const int indent) const noexcept { return toJSONObject().dump(0); }

std::string Graph::toString() const noexcept
{
std::stringstream ss;
Expand Down Expand Up @@ -255,11 +185,11 @@ std::string Graph::toString() const noexcept
auto it = nodes.cbegin();
for (int i = 0; i < getNodesCount(); ++i, ++it)
{
ss << it->first << ' ';
ss << it->label << ' ';
ss << "| ";
for (const auto &key : nodes | std::views::keys)
for (const auto &[label, occurrence] : nodes)
{
ss << key << ' ';
ss << label << ' ';
}
ss << "| ";
}
Expand All @@ -269,7 +199,7 @@ std::string Graph::toString() const noexcept

for (int i = 0; i < getNodesCount(); ++i, ++it)
{
ss << "\t" << it->first << " | ";
ss << "\t" << it->label << " | ";

int j = 0;
for (const int &key : CLM[i])
Expand Down

0 comments on commit d3ac08e

Please sign in to comment.