10000 Added documentation for the Node class · TheAlgorithms/C-Plus-Plus@a905279 · GitHub
[go: up one dir, main page]

Skip to content

Commit a905279

Browse files
Added documentation for the Node class
1 parent e5644e7 commit a905279

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

graph/a_star.cpp

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,15 @@
2424
*/
2525
namespace graph {
2626

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+
*/
2731
class Node {
2832
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
3236

3337
public:
3438
Node(size_t idx, std::pair<int, int> pos, std::vector<size_t> conn = {}) {
@@ -41,9 +45,30 @@ class Node {
4145
}
4246
}
4347

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+
*/
4454
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+
*/
4560
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+
*/
4666
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+
*/
4772
std::pair<int, int> get_pos() { return this->_pos; }
4873
};
4974

0 commit comments

Comments
 (0)
0