FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

GitHub Viewer

#include "node.hpp" #include #include "mgp.hpp" namespace { std::unordered_map GetTypeDirection(const mgp::Value &types) { std::unordered_map result; for (const auto &type_value : types.ValueList()) { auto type = type_value.ValueString(); if (type.starts_with('')) { throw mgp::ValueException(" format not allowed. Use type instead."); } result[type.substr(1, type.size() - 1)] |= 1; } else if (type.ends_with('>')) { result[type.substr(0, type.size() - 1)] |= 2; } else { result[type] |= 3; } } return result; } mgp::List GetRelationshipTypes(const mgp::Value &node_value, const mgp::Value &types_value) { auto type_direction = GetTypeDirection(types_value); std::unordered_set types; const auto node = node_value.ValueNode(); if (type_direction.empty()) { for (const auto relationship : node.InRelationships()) { types.insert(relationship.Type()); } for (const auto relationship : node.OutRelationships()) { types.insert(relationship.Type()); } } else { for (const auto relationship : node.InRelationships()) { if (type_direction[relationship.Type()] & 1) { types.insert(relationship.Type()); } } for (const auto relationship : node.OutRelationships()) { if (type_direction[relationship.Type()] & 2) { types.insert(relationship.Type()); } } } mgp::List result{types.size()}; for (const auto &type : types) { auto value = mgp::Value(type); result.Append(value); } return result; } } // namespace bool Node::RelationshipExist(const mgp::Node &node, std::string &rel_type) { char direction{' '}; if (rel_type[0] == '') { throw mgp::ValueException("Invalid relationship specification!"); } else if (rel_type[rel_type.size() - 1] == '>') { direction = rel_type[rel_type.size() - 1]; rel_type.pop_back(); } else if (rel_type[0] == '

Back | FazBrowse Home | New Git URL