Add InDegree and OutDegree in O(1) (#1217)

This commit is contained in:
Matija Pintarić
2023-09-07 13:16:30 +02:00
committed by GitHub
parent 312d01bd0c
commit d9464c6ffd
6 changed files with 88 additions and 0 deletions

View File

@@ -752,6 +752,12 @@ class Node {
/// @brief returns the string representation
const std::string ToString() const;
/// @brief returns the in degree of a node
inline size_t InDegree() const;
/// @brief returns the out degree of a node
inline size_t OutDegree() const;
private:
mgp_vertex *ptr_;
};
@@ -2790,6 +2796,10 @@ inline const std::string Node::ToString() const {
return "(id: " + std::to_string(Id().AsInt()) + labels + ", properties: {" + properties + "})";
}
inline size_t Node::InDegree() const { return mgp::vertex_get_in_degree(ptr_); }
inline size_t Node::OutDegree() const { return mgp::vertex_get_out_degree(ptr_); }
// Relationship:
inline Relationship::Relationship(mgp_edge *ptr) : ptr_(mgp::MemHandlerCallback(edge_copy, ptr)) {}