From 33c50d99e199dfbd3c887c8d319e641f73331e9c Mon Sep 17 00:00:00 2001 From: Prerak Shah Date: Fri, 3 Oct 2025 22:44:31 +0530 Subject: [PATCH 1/2] Update graph_models.cpp update constructors to initialize color for nodes and edges --- cpp/src/models/graph_models.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cpp/src/models/graph_models.cpp b/cpp/src/models/graph_models.cpp index 69c33a2..fdd21b2 100644 --- a/cpp/src/models/graph_models.cpp +++ b/cpp/src/models/graph_models.cpp @@ -1,10 +1,10 @@ #include "models/graph_models.h" -GraphNode::GraphNode(int id, const std::string& label, double x, double y) - : id(id), label(label), x(x), y(y) {} +GraphNode::GraphNode(int id, const std::string& label, double x, double y, const std::string& color) + : id(id), label(label), x(x), y(y), color(color) {} -GraphEdge::GraphEdge(int from, int to, double weight, bool directed) - : from(from), to(to), weight(weight), directed(directed) {} +GraphEdge::GraphEdge(int from, int to, double weight, bool directed, const std::string& color) + : from(from), to(to), weight(weight), directed(directed), color(color) {} GraphStep::GraphStep(const std::string& operation) : operation(operation) {} From dd0c48da768ea81e55959bb7ac6013c9a7b68601 Mon Sep 17 00:00:00 2001 From: Prerak Shah Date: Fri, 3 Oct 2025 22:48:07 +0530 Subject: [PATCH 2/2] Update graph_models.h add color attribute to GraphNode and GraphEdge --- cpp/include/models/graph_models.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cpp/include/models/graph_models.h b/cpp/include/models/graph_models.h index 4002e1d..6eb7526 100644 --- a/cpp/include/models/graph_models.h +++ b/cpp/include/models/graph_models.h @@ -7,18 +7,22 @@ struct GraphNode { int id; std::string label; double x, y; - - GraphNode(int id, const std::string& label = "", double x = 0.0, double y = 0.0); + std::string color; + + GraphNode(int id, const std::string& label = "", double x = 0.0, double y = 0.0, const std::string& color = "white"); }; + struct GraphEdge { int from, to; double weight; bool directed; - - GraphEdge(int from, int to, double weight = 1.0, bool directed = false); + std::string color; + + GraphEdge(int from, int to, double weight = 1.0, bool directed = false, const std::string& color = "black"); }; + struct GraphStep { std::vector visitedNodes; std::vector currentNodes;