24
24
*/
25
25
namespace graph {
26
26
27
+ /* *
28
+ * @brief A fundamental unit of a graph. Contains the location (x, y) of the node, a
29
+ * unique index identifying the node, and a list of all connected nodes.
30
+ */
27
31
class Node {
28
32
private:
29
- size_t _idx; // A unique identifier for a given graph
30
- std::pair<int , int > _pos; // Coordinates denoting the location of the node
31
- std::vector<size_t > _connections; // A list of indexes of connected nodes
33
+ size_t _idx; // < A unique identifier for a given graph
34
+ std::pair<int , int > _pos; // < Coordinates denoting the location of the node
35
+ std::vector<size_t > _connections; // < A list of indexes of connected nodes
32
36
33
37
public:
34
38
Node (size_t idx, std::pair<int , int > pos, std::vector<size_t > conn = {}) {
@@ -41,9 +45,30 @@ class Node {
41
45
}
42
46
}
43
47
48
+ /* *
49
+ * @brief Appends the index of another node to this node's list of
50
+ * connections
51
+ * @param conn the unique index of a node connected to this node
52
+ * @returns void
53
+ */
44
54
void add_connection (size_t conn) { this ->_connections .push_back (conn); }
55
+
56
+ /* *
57
+ * @brief Retrives the unique identifing number (index) of this node
58
+ * @returns the index of the node
59
+ */
45
60
size_t get_idx () { return this ->_idx ; }
61
+
62
+ /* *
63
+ * @brief Retrives the list of unique indexes for nodes connected to this one
64
+ * @returns the list of the connected nodes
65
+ */
46
66
std::vector<size_t > get_connections () { return this ->_connections ; }
67
+
68
+ /* *
69
+ * @brief Retrives the co-ordinates of the node
70
+ * @returns a pair (x,y) of co-ordinates for the node
71
+ */
47
72
std::pair<int , int > get_pos () { return this ->_pos ; }
48
73
};
49
74
0 commit comments