implement edge removal
This commit is contained in:
parent
5505257daa
commit
2285790521
src/query
@ -53,8 +53,10 @@ const std::string &SubgraphDbAccessor::EdgeTypeToName(storage::EdgeTypeId type)
|
||||
|
||||
storage::Result<std::optional<EdgeAccessor>> SubgraphDbAccessor::RemoveEdge(EdgeAccessor *edge) {
|
||||
auto result = db_accessor_->RemoveEdge(edge);
|
||||
// todo antoniofilipovic remove edge from subgraph
|
||||
return result;
|
||||
if (result.HasError() || !*result) {
|
||||
return result;
|
||||
}
|
||||
return this->graph_->RemoveEdge(*edge);
|
||||
}
|
||||
|
||||
storage::Result<EdgeAccessor> SubgraphDbAccessor::InsertEdge(SubgraphVertexAccessor *from, SubgraphVertexAccessor *to,
|
||||
@ -85,7 +87,6 @@ storage::Result<std::optional<VertexAccessor>> SubgraphDbAccessor::RemoveVertex(
|
||||
return result;
|
||||
}
|
||||
return this->graph_->RemoveVertex(*vertex_accessor);
|
||||
;
|
||||
}
|
||||
|
||||
SubgraphVertexAccessor SubgraphDbAccessor::InsertVertex() {
|
||||
|
@ -53,6 +53,14 @@ std::optional<VertexAccessor> Graph::RemoveVertex(const VertexAccessor &vertex)
|
||||
return vertex;
|
||||
}
|
||||
|
||||
std::optional<EdgeAccessor> Graph::RemoveEdge(const EdgeAccessor &edge) {
|
||||
auto value = edges_.erase(edge);
|
||||
if (value == 0) {
|
||||
return std::nullopt;
|
||||
}
|
||||
return edge;
|
||||
}
|
||||
|
||||
std::vector<query::EdgeAccessor> Graph::OutEdges(query::VertexAccessor vertex_accessor) {
|
||||
std::vector<query::EdgeAccessor> out_edges;
|
||||
for (auto it = edges_.begin(); it != edges_.end(); ++it) {
|
||||
|
@ -61,6 +61,7 @@ class Graph final {
|
||||
void InsertEdge(const EdgeAccessor &edge);
|
||||
bool ContainsVertex(const VertexAccessor &vertex);
|
||||
std::optional<VertexAccessor> RemoveVertex(const VertexAccessor &vertex);
|
||||
std::optional<EdgeAccessor> RemoveEdge(const EdgeAccessor &edge);
|
||||
|
||||
std::vector<EdgeAccessor> OutEdges(VertexAccessor vertex_accessor);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user