From 4e978f1dddaa3520e01a3fc0e105c07c81044bcd Mon Sep 17 00:00:00 2001 From: Abdur Rahman Goraya Date: Fri, 29 Dec 2023 23:11:26 +0500 Subject: [PATCH] Renamed Graph.h -> Graph.hpp Took 3 minutes --- include/{Graph.h => Graph.hpp} | 43 +++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 19 deletions(-) rename include/{Graph.h => Graph.hpp} (68%) diff --git a/include/Graph.h b/include/Graph.hpp similarity index 68% rename from include/Graph.h rename to include/Graph.hpp index 9a1246e..2fd45ae 100644 --- a/include/Graph.h +++ b/include/Graph.hpp @@ -7,10 +7,30 @@ class Graph { + struct Node { + char label{}; + uint occurrence{}; + + bool operator<(const Node & rhs) const { + return label < rhs.label; + } + + NLOHMANN_DEFINE_TYPE_INTRUSIVE(Node, label, occurrence); + }; + + struct Edge { + char from{}; + char to{}; + std::list extraNodes; + uint occurrence{}; + + NLOHMANN_DEFINE_TYPE_INTRUSIVE(Edge, from, to, extraNodes, occurrence); + }; + std::list transactions; std::list jsonHistory; - std::list> nodes; - std::list, int>> rawEdges; + std::list nodes; + std::list rawEdges; std::vector> CLM; /** @@ -35,13 +55,9 @@ class Graph */ [[nodiscard]] int mapNodeToPosition(char node) const noexcept; - /** - * \brief Returns an image of the graphs current state excluding json history - * \return A JSON object representing the graph - */ - [[nodiscard]] nlohmann::json toJSONObject() const noexcept; - public: + NLOHMANN_DEFINE_TYPE_INTRUSIVE(Graph, transactions, nodes, rawEdges, CLM, jsonHistory); + /** * \brief Processes the passed string into the graph generating new nodes and * edges \param str The transaction to process @@ -53,17 +69,6 @@ class Graph */ void processCLM(); - /** - * \return The JSON history in chronological order (0 being the oldest) - */ - [[nodiscard]] std::string getJSONHistoryAsJSON() const noexcept; - - /** - * \brief Serializes all of the graph data excluding JSON history into a JSON - * nlohmann::json \return The JSON string - */ - [[nodiscard]] std::string toJSON(int indent = 0) const noexcept; - /** * \brief Serializes all of the graph data excluding JSON history into a * string \return The resultant string