Template Class EdgeIndex

Inheritance Relationships

Base Type

Class Documentation

template <typename SrcT, typename DestT, typename StorageT = DefaultEdgeIndexStorage<SrcT, DestT>>
class EdgeIndex : public shad::AbstractDataStructure<EdgeIndex<SrcT, DestT, StorageT>>

The EdgeIndex data structure.

SHAD’s EdgeIndex is a thread-safe, associative container, representing a collection of neighbors lists of a graph.

Warning
obects of type SrcT and DestT need to be trivially copiable.
Template Parameters
  • SrcT: type of source vertices (used as identifiers).
  • DestT: type of destination vertices (used as identifiers).
Template Parameters
  • StorageT: EdgeIndex local storage. Default is a map of sets.

Public Types

template<>
using ObjectID = typename AbstractDataStructure::ObjectID
template<>
using EdgeListPtr = typename AbstractDataStructure<EdgeIndex<SrcT, DestT, StorageT>>::SharedPtr
template<>
using SrcType = SrcT
template<>
using DestType = DestT
template<>
using LIdxT = LocalEdgeIndex<SrcT, DestT, StorageT>
template<>
using IdxT = EdgeIndex<SrcT, DestT, StorageT>
template<>
using BuffersVector = typename impl::BuffersVector<EntryT, EdgeIndex<SrcT, DestT, StorageT>>

Public Functions

ObjectID GetGlobalID() const

Create method.

Creates a new edge_index instance.

Return
A shared pointer to the newly created edge_index instance. Getter of the Global Identifier.
Return
The global identifier associated with the hashmap instance.
Parameters
  • numVertices: Expected number of vertices.

size_t Size() const

Overall size of the edge index (number of unique sources).

Return
the number of unique source vertices in the index.

size_t NumEdges()

Overall number of edges in the index.

Return
the number of edges in the index.

void Insert(const SrcT &src, const DestT &dest)

Insert an edge in the index.

Parameters
  • src: the source vertex.
  • value: the destination vertex.

void AsyncInsert(rt::Handle &handle, const SrcT &src, const DestT &dest)

Asynchronously insert an edge in the index.

Warning
Asynchronous operations are guaranteed to have completed only after calling the rt::waitForCompletion(rt::Handle &handle) method.
Parameters
  • handle: Reference to the handle to be used to wait for completion.
Parameters
  • src: the source vertex.
  • value: the destination vertex.

void InsertEdgeList(const SrcT &src, DestT *destinations, size_t numDest, bool overwrite = true)

Insert an edge list in the index.

Parameters
  • src: the source vertex.
  • destinations: pointer to the destination vertices.
  • numDest: number of destinations (edges) to insert.
  • overwrite: if true, overwrites the neighbors list of src with the provided destinations; otherwise, edges are added to the current neighbors list.

void AsyncInsertEdgeList(rt::Handle &handle, const SrcT &src, DestT *destinations, size_t numDest, bool overwrite = true)

Asynchronously insert an edge list in the index.

Warning
Asynchronous operations are guaranteed to have completed only after calling the rt::waitForCompletion(rt::Handle &handle) method.
Parameters
  • handle: Reference to the handle to be used to wait for completion.
Parameters
  • src: the source vertex.
  • destinations: pointer to the destination vertices.
  • numDest: number of destinations (edges) to insert.
  • overwrite: if true, overwrites the neighbors list of src with the provided destinations; otherwise, edges are added to the current neighbors list.

void AsyncGetNeighbors(rt::Handle &handle, const SrcT src, typename StorageT::NeighborListStorageT **res)

Asynchronously retrieve the neighbors list of a given vertex.

Warning
Asynchronous operations are guaranteed to have completed only after calling the rt::waitForCompletion(rt::Handle &handle) method.
Parameters
  • handle: Reference to the handle to be used to wait for completion.
Parameters
  • src: the source vertex.
  • res: pointer to the neighbors list storage where the neighbors list of src is stored.

void GetNeighbors(const SrcT &src, typename StorageT::NeighborListStorageT *res)

Retrieve the neighbors list of a given vertex.

Parameters
  • src: the source vertex.
  • res: pointer to the neighbors list storage where the neighbors list of src is copied.

size_t GetDegree(const SrcT &src)

Number of neighbors of a given vertex.

Return
the number of neighbors of vertex src.
Parameters
  • src: the source vertex.

void BufferedInsert(const SrcT &src, const DestT &dest)

Buffered Insert method.

Inserts an edge, using aggregation buffers.

Warning
Insertions are finalized only after calling the WaitForBufferedInsert() method.
Parameters
  • src: The source vertex.
  • dest: The destination vertex.

void BufferedAsyncInsert(rt::Handle &handle, const SrcT &src, const DestT &dest)

Asynchronous Buffered Insert method.

Asynchronously inserts an edge, using aggregation buffers.

Warning
asynchronous buffered insertions are finalized only after calling the rt::waitForCompletion(rt::Handle &handle) method and the WaitForBufferedInsert() method, in this order.
Parameters
  • handle: Reference to the handle
  • src: The source vertex.
  • dest: The destination vertex.

void WaitForBufferedInsert()

Finalize method for buffered insertions.

void Erase(const SrcT &src, const DestT &dest)

Delete an edge.

Parameters
  • src: The source vertex.
  • dest: The destination vertex.

void AsyncErase(rt::Handle &handle, const SrcT &src, const DestT &dest)

Asynchronously delete an edge.

Warning
Asynchronous operations are guaranteed to have completed only after calling the rt::waitForCompletion(rt::Handle &handle) method.
Parameters
  • handle: Reference to the handle to be used to wait for completion.
Parameters
  • src: The source vertex.
  • dest: The destination vertex.

void Erase(const SrcT &src)

Remove a vertex from the edge index.

Parameters
  • src: the src vertex.

void Clear()

Clear the content of the edge index.

void BufferEntryInsert(const EntryT &entry)
template <typename ApplyFunT, typename... Args>
void ForEachNeighbor(const SrcT &src, ApplyFunT &&function, Args&... args)

Apply a user-defined function to each neighbor of a given vertex.

Template Parameters
  • ApplyFunT: User-defined function type. The function prototype should be:
    void(const SrcT&, const DestT&, Args&);
    
  • ...Args: Types of the function arguments.
Parameters
  • src: The source vertex
  • function: The function to apply.
  • args: The function arguments.

template <typename ApplyFunT, typename... Args>
void AsyncForEachNeighbor(rt::Handle &handle, const SrcT &src, ApplyFunT &&function, Args&... args)

Asynchronously apply a user-defined function to each neighbor of a given vertex.

Warning
Asynchronous operations are guaranteed to have completed only after calling the
Template Parameters
  • ApplyFunT: User-defined function type. The function prototype should be:
    void(Handle&, const SrcT&, const DestT&, Args&);
    
  • ...Args: Types of the function arguments.
Parameters
  • handle: Reference to the handle to be used to wait for completion.
Parameters
  • src: The source vertex.
  • function: The function to apply.
  • args: The function arguments.

template <typename ApplyFunT, typename... Args>
void ForEachVertex(ApplyFunT &&function, Args&... args)

Apply a user-defined function to each vertex.

Template Parameters
  • ApplyFunT: User-defined function type. The function prototype should be:
    void(const SrcT&, Args&);
    
  • ...Args: Types of the function arguments.
Parameters
  • function: The function to apply.
  • args: The function arguments.

template <typename ApplyFunT, typename... Args>
void AsyncForEachVertex(rt::Handle &handle, ApplyFunT &&function, Args&... args)

Apply a user-defined function to each vertex.

Warning
Asynchronous operations are guaranteed to have completed only after calling the
Template Parameters
  • ApplyFunT: User-defined function type. The function prototype should be:
    void(const SrcT&, Args&);
    
  • ...Args: Types of the function arguments.
Parameters
  • handle: Reference to the handle to be used to wait for completion.
Parameters
  • function: The function to apply.
  • args: The function arguments.

template <typename ApplyFunT, typename... Args>
void ForEachEdge(ApplyFunT &&function, Args&... args)

Apply a user-defined function to each edge.

Template Parameters
  • ApplyFunT: User-defined function type. The function prototype should be:
    void(const SrcT&, const DestT&, Args&);
    
  • ...Args: Types of the function arguments.
Parameters
  • function: The function to apply.
  • args: The function arguments.

template <typename ApplyFunT, typename... Args>
void AsyncForEachEdge(rt::Handle &handle, ApplyFunT &&function, Args&... args)

Asynchronously apply a user-defined function to each edge.

Warning
Asynchronous operations are guaranteed to have completed only after calling the
Template Parameters
  • ApplyFunT: User-defined function type. The function prototype should be:
    void(Handle&, const SrcT&, const DestT&, Args&);
    
  • ...Args: Types of the function arguments.
Parameters
  • handle: Reference to the handle to be used to wait for completion.
Parameters
  • function: The function to apply.
  • args: The function arguments.

LocalEdgeIndex<SrcT, DestT, StorageT> *GetLocalIndexPtr()
bool GetVertexAttributes(const SrcT &src, typename StorageT::SrcAttributesT *attr)

Retrieve the attributes of a given vertex.

Return
true if the vertex has been found, false otherwise.
Parameters
  • src: the source vertex.
  • attr: pointer to the attributes data structure where the attributes are copied.

template <typename ApplyFunT, typename... Args>
void VertexAttributesApply(const SrcT &src, ApplyFunT &&function, Args&... args)

Apply a user-defined function to the attributes of a given vertex.

Template Parameters
  • ApplyFunT: User-defined function type. The function prototype should be:
    void(const SrcT&, StorageT::SrcAttributesT&, Args&);
    
  • ...Args: Types of the function arguments.
Parameters
  • src: the source vertex.
  • function: The function to apply.
  • args: The function arguments.

Protected Functions

EdgeIndex(ObjectID oid, const size_t numVertices)
EdgeIndex(ObjectID oid, const size_t numVertices, const typename StorageT::SrcAttributesT &initAttr)
struct EntryT

Public Functions

template<>
EntryT(const SrcT &s, const DestT &d)
template<>
EntryT()

Public Members

template<>
SrcT src
template<>
DestT dest