lgraph_edge_iterator

namespace lgraph
namespace graph
namespace lgraph_api

Functions

bool operator==(const OutEdgeIterator &lhs, const OutEdgeIterator &rhs)

Check whether lhs and rhs points to the same edge.

bool operator==(const OutEdgeIterator &lhs, const InEdgeIterator &rhs)

Check whether lhs and rhs points to the same edge.

bool operator==(const InEdgeIterator &lhs, const OutEdgeIterator &rhs)

Check whether lhs and rhs points to the same edge.

bool operator==(const InEdgeIterator &lhs, const InEdgeIterator &rhs)

Check whether lhs and rhs points to the same edge.

bool operator!=(const OutEdgeIterator &lhs, const OutEdgeIterator &rhs)

Check whether lhs and rhs points to the same edge.

bool operator!=(const OutEdgeIterator &lhs, const InEdgeIterator &rhs)

Check whether lhs and rhs points to the same edge.

bool operator!=(const InEdgeIterator &lhs, const OutEdgeIterator &rhs)

Check whether lhs and rhs points to the same edge.

bool operator!=(const InEdgeIterator &lhs, const InEdgeIterator &rhs)

Check whether lhs and rhs points to the same edge.

class InEdgeIterator
#include <lgraph_edge_iterator.h>

An InEdgeIterator can be used to iterate through the in-coming edges of a vertex. Edges are sorted in (lid, tid, src, eid) order, and each (dst, lid, tid, src, eid) tuple is guaranteed to uniquely identify an edge.

An InEdgeIterator is valid iff it points to a valid in-coming edge, otherwise it is invalid. Calling member function on an invalid InEdgeIterator throws an exception, except for the IsValid() and Goto() functions.

The following operations invalidates an InEdgeIterator:

  1. Constructing an InEdgeIterator for non-existing edge.

  2. Calling Goto() with the id of a non-existing edge.

  3. Calling Next() on the last in-coming edge.

  4. Calling Delete() on the last in-coming edge.

  5. Calling Close() on the iterator.

In TuGraph, every iterator belongs to a transaction, and can only be used when the transaction is valid. Calling member functions on an iterator inside an invalid transaction yields InvalidTxnError, except for Invalid().

Public Functions

InEdgeIterator(InEdgeIterator &&rhs)
InEdgeIterator &operator=(InEdgeIterator&&)
~InEdgeIterator()
void Close() noexcept

Closes this iterator. The iterator turns invalid after being closed.

bool Next()

Move to the next incoming edge to current destination vertex. If there is no more edge, the iterator becomes invalid and false is returned.

抛出
返回

True if it succeeds, false if it fails.

bool Goto(EdgeUid euid, bool nearest = false)

Go to the edge specified by euid. If the specified edge cannot be found and nearest==true, then try to get the next in-coming edge to the vertex euid.dst, sorted by (label, tid, src, eid). If there is no such edge, iterator is invalidated and false is returned.

抛出
参数
  • euid – Edge Unique Id.

  • nearest – (Optional) True to get the nearest edge if the specified one cannot be found.

返回

True if it succeeds, false if it fails.

EdgeUid GetUid() const

Gets the Edge Unique Id

抛出
返回

The UID.

int64_t GetSrc() const

Gets the source vertex id.

抛出
返回

The source vertex id.

int64_t GetDst() const

Gets destination vertex id.

抛出
返回

The destination vertex id.

int64_t GetEdgeId() const

Gets edge id.

抛出
返回

The edge id.

int64_t GetTemporalId() const

Gets temporal id.

抛出
返回

The temporal id.

bool IsValid() const

Query if this iterator is valid.

抛出
返回

True if valid, false if not.

const std::string &GetLabel() const

Gets the label of this edge.

抛出
返回

The label.

int16_t GetLabelId() const

Gets label id of this edge.

抛出
返回

The label identifier.

std::vector<FieldData> GetFields(const std::vector<std::string> &field_names) const

Gets the fields specified.

抛出
参数

field_names – List of names of the fields.

返回

The fields.

FieldData GetField(const std::string &field_name) const

Gets the field specified.

抛出
参数

field_name – Field name.

返回

Field value.

std::vector<FieldData> GetFields(const std::vector<size_t> &field_ids) const

Gets the fields specified.

抛出
参数

field_ids – List of ids for the fields.

返回

The fields.

FieldData GetField(size_t field_id) const

Gets the field specified.

抛出
参数

field_id – Field ID.

返回

Field value.

inline FieldData operator[](const std::string &field_name) const

Get field identified by field_name

抛出
参数

field_name – Filename of the file.

返回

The indexed value.

inline FieldData operator[](size_t fid) const

Get field identified by field id

抛出
参数

fid – The field id.

返回

The indexed value.

std::map<std::string, FieldData> GetAllFields() const

Gets all fields of current vertex.

抛出
返回

All field names and values stored as a {(field_name, field_value),…} map.

void SetField(const std::string &field_name, const FieldData &field_value)

Sets the specified field.

抛出
参数
  • field_name – Field name.

  • field_value – Field value.

void SetField(size_t field_id, const FieldData &field_value)

Sets the specified field.

抛出
参数
  • field_id – Field id.

  • field_value – Field value.

void SetFields(const std::vector<std::string> &field_names, const std::vector<std::string> &field_value_strings)

Sets the fields specified.

抛出
参数
  • field_names – List of names of the fields.

  • field_value_strings – The field value strings.

void SetFields(const std::vector<std::string> &field_names, const std::vector<FieldData> &field_values)

Sets the fields specified.

抛出
参数
  • field_names – List of names of the fields.

  • field_values – The field values.

void SetFields(const std::vector<size_t> &field_ids, const std::vector<FieldData> &field_values)

Sets the fields specified.

抛出
参数
  • field_ids – List of identifiers for the fields.

  • field_values – The field values.

void Delete()

Deletes this edge. The iterator will point to the next incoming edge sorted by (lid, tid, src, eid) if there is any. If no in-coming edge is left for this vertex, the iterator becomes invalid.

抛出
std::string ToString() const

Get string representation of the edge.

Private Functions

InEdgeIterator(lgraph::graph::InEdgeIterator&&, const std::shared_ptr<lgraph::Transaction>&)

Constructors are private, use Transaction::GetInEdgeIterator() or VertexIterator::GetInEdgeIterator() instead.

InEdgeIterator(const InEdgeIterator&) = delete
InEdgeIterator &operator=(const InEdgeIterator&) = delete

Private Members

std::unique_ptr<lgraph::graph::InEdgeIterator> it_
std::shared_ptr<lgraph::Transaction> txn_

Friends

friend class Transaction
friend class VertexIterator
class OutEdgeIterator
#include <lgraph_edge_iterator.h>

An OutEdgeIterator can be used to iterate through the out-going edges of a vertex. Edges are sorted in (lid, dst, eid) order, and each (src, lid, tid, dst, eid) tuple is guaranteed to uniquely identify an edge.

An OutEdgeIterator is valid iff it points to a valid out-going edge, otherwise it is invalid. Calling member function on an invalid OutEdgeIterator throws an InvalidIteratorError, except for the IsValid() and Goto() functions.

The following operations invalidates an OutEdgeIterator:

  1. Constructing an OutEdgeIterator for non-existing edge.

  2. Calling Goto() with the id of a non-existing edge.

  3. Calling Next() on the last out-going edge.

  4. Calling Delete() on the last out-going edge.

  5. Calling Close() on the iterator.

In TuGraph, every iterator belongs to a transaction, and can only be used when the transaction is valid. Calling member functions on an iterator inside an invalid transaction yields InvalidTxnError, except for Invalid().

Public Functions

OutEdgeIterator(OutEdgeIterator &&rhs)
OutEdgeIterator &operator=(OutEdgeIterator &&rhs)
~OutEdgeIterator()
void Close() noexcept

Closes this iterator. The iterator turns invalid after being closed.

bool Goto(EdgeUid euid, bool nearest = false)

Go to the edge specified by euid. That is, an edge from Vertex euid.src to euid.dst, with LabelId==euid.label, Tid==euid.tid, and EdgeId==euid.eid. If neareast==true and the exact edge was not found, the iterator tries to get the next edge that sorts after the specified edge. The edges are sorted in (label, tid, dst, eid) order. The iterator becomes invalid if there is no outgoing edge from euid.src that sorts after euid.

抛出

InvalidTxnError – Thrown when called inside an invalid transaction.

参数
  • euid – Edge Unique ID.

  • nearest – (Optional) True to get the nearest edge if the specified one cannot be found.

返回

True if it succeeds, false if there is no such edge.

bool IsValid() const noexcept

Query if this iterator is valid.

返回

True if valid, false if not.

bool Next()

Move to the next edge. Invalidates iterator if there is no more out edges from current source vertex.

抛出
返回

True if it succeeds, false if it fails (no more out edge from current source).

EdgeUid GetUid() const

Gets the Edge Unique Id

抛出
返回

The UID.

int64_t GetDst() const

Gets destination of the edge.

抛出
返回

The destination vertex id.

int64_t GetEdgeId() const

Gets edge id.

抛出
返回

The edge identifier.

int64_t GetTemporalId() const

Gets primary id.

抛出
返回

The primary id of the edge.

int64_t GetSrc() const

Gets the source vertex id.

抛出
返回

The source vertex id.

const std::string &GetLabel() const

Gets the label of this edge.

抛出
返回

The label.

int16_t GetLabelId() const

Gets label id of this edge.

抛出
返回

The label identifier.

std::vector<FieldData> GetFields(const std::vector<std::string> &field_names) const

Gets the fields specified.

抛出
参数

field_names – List of names of the fields.

返回

The fields.

FieldData GetField(const std::string &field_name) const

Gets the field specified.

抛出
参数

field_name – Field name.

返回

Field value.

std::vector<FieldData> GetFields(const std::vector<size_t> &field_ids) const

Gets the fields specified.

抛出
参数

field_ids – List of ids for the fields.

返回

The fields.

FieldData GetField(size_t field_id) const

Gets the field specified.

抛出
参数

field_id – Field ID.

返回

Field value.

inline FieldData operator[](const std::string &field_name) const

Get field identified by field_name.

抛出
参数

field_name – The name of the field to get.

返回

Field value.

inline FieldData operator[](size_t fid) const

Get field identified by field id. FieldId can be obtained with txn.GetEdgeFieldId()

抛出
参数

fid – fid The field id.

返回

Field value.

std::map<std::string, FieldData> GetAllFields() const

Gets all fields of current vertex.

抛出
返回

All fields in a dictionary of {(field_name, field_value),…}.

void SetField(const std::string &field_name, const FieldData &field_value)

Sets the specified field.

抛出
参数
  • field_name – Field name.

  • field_value – Field value.

void SetField(size_t field_id, const FieldData &field_value)

Sets the specified field.

抛出
参数
  • field_id – Field id.

  • field_value – Field value.

void SetFields(const std::vector<std::string> &field_names, const std::vector<std::string> &field_value_strings)

Sets the fields specified.

抛出
参数
  • field_names – List of names of the fields.

  • field_value_strings – The field value in string representation.

void SetFields(const std::vector<std::string> &field_names, const std::vector<FieldData> &field_values)

Sets the fields specified.

抛出
参数
  • field_names – List of names of the fields.

  • field_values – The field values.

void SetFields(const std::vector<size_t> &field_ids, const std::vector<FieldData> &field_values)

Sets the fields specified.

抛出
参数
  • field_ids – List of identifiers for the fields.

  • field_values – The field values.

void Delete()

Deletes this edge. The iterator will point to the next out-going edge sorted by (label, tid, dst, eid) if there is any. If there is no more out-going edges for this source vertex, the iterator becomes invalid.

抛出
std::string ToString() const

Get string representation of the edge.

抛出
返回

A std::string that represents this object.

Private Functions

OutEdgeIterator(lgraph::graph::OutEdgeIterator&&, const std::shared_ptr<lgraph::Transaction>&)

Constructors are private, use Transaction::GetInEdgeIterator() or VertexIterator::GetInEdgeIterator() instead.

OutEdgeIterator(const OutEdgeIterator&) = delete
OutEdgeIterator &operator=(const OutEdgeIterator&) = delete

Private Members

std::unique_ptr<lgraph::graph::OutEdgeIterator> it_
std::shared_ptr<lgraph::Transaction> txn_

Friends

friend class Transaction
friend class VertexIterator