memgraph/include/storage/vertex_accessor.hpp

66 lines
1.6 KiB
C++
Raw Normal View History

#pragma once
#include "storage/label/label_collection.hpp"
#include "storage/record_accessor.hpp"
#include "storage/vertex.hpp"
#include "utils/iterator/iterator.hpp"
class Vertices;
class EdgeAccessor;
// There exists circular dependecy with EdgeAccessor.
class VertexAccessor : public RecordAccessor<TypeGroupVertex, VertexAccessor>
{
friend EdgeAccessor;
public:
using RecordAccessor::RecordAccessor;
using record_t = Vertex;
using record_list_t = VertexRecord;
2016-08-30 15:53:02 +08:00
// Removes self and all edges connected to it.
void remove() const;
// Returns number of out edges.
size_t out_degree() const;
// Returns number of in edges.
size_t in_degree() const;
// Returns number of all edges.
size_t degree() const;
// True if vertex isn't connected to any other vertex.
bool isolated() const;
// False if it already has the label.
bool add_label(const Label &label);
// False if it doesn't have the label.
bool remove_label(const Label &label);
// Checks if it has the label.
bool has_label(const Label &label) const;
// Returns container with all labels.
2016-08-28 22:47:13 +08:00
const std::vector<label_ref_t> &labels() const;
auto out() const;
auto in() const;
// True if there exists edge between other vertex and this vertex.
bool in_contains(VertexAccessor const &other) const;
template <typename Stream>
void stream_repr(Stream& stream) const
{
if (this->record != nullptr)
this->record->stream_repr(stream);
else
std::cout << "TRACE: record is nullptr" << std::endl;
}
};