Skip to content

Commit a69b869

Browse files
authored
Merge pull request #24 from PrerakShah101/main
add color attribute to GraphNode and GraphEdge
2 parents b48795d + dd0c48d commit a69b869

2 files changed

Lines changed: 12 additions & 8 deletions

File tree

cpp/include/models/graph_models.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,22 @@ struct GraphNode {
77
int id;
88
std::string label;
99
double x, y;
10-
11-
GraphNode(int id, const std::string& label = "", double x = 0.0, double y = 0.0);
10+
std::string color;
11+
12+
GraphNode(int id, const std::string& label = "", double x = 0.0, double y = 0.0, const std::string& color = "white");
1213
};
1314

15+
1416
struct GraphEdge {
1517
int from, to;
1618
double weight;
1719
bool directed;
18-
19-
GraphEdge(int from, int to, double weight = 1.0, bool directed = false);
20+
std::string color;
21+
22+
GraphEdge(int from, int to, double weight = 1.0, bool directed = false, const std::string& color = "black");
2023
};
2124

25+
2226
struct GraphStep {
2327
std::vector<int> visitedNodes;
2428
std::vector<int> currentNodes;

cpp/src/models/graph_models.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#include "models/graph_models.h"
22

3-
GraphNode::GraphNode(int id, const std::string& label, double x, double y)
4-
: id(id), label(label), x(x), y(y) {}
3+
GraphNode::GraphNode(int id, const std::string& label, double x, double y, const std::string& color)
4+
: id(id), label(label), x(x), y(y), color(color) {}
55

6-
GraphEdge::GraphEdge(int from, int to, double weight, bool directed)
7-
: from(from), to(to), weight(weight), directed(directed) {}
6+
GraphEdge::GraphEdge(int from, int to, double weight, bool directed, const std::string& color)
7+
: from(from), to(to), weight(weight), directed(directed), color(color) {}
88

99
GraphStep::GraphStep(const std::string& operation)
1010
: operation(operation) {}

0 commit comments

Comments
 (0)