Apache GraphAr C++ Library
The C++ Library for Apache GraphAr
Classes | Public Member Functions | Static Public Member Functions | List of all members
graphar::GraphInfo Class Reference

#include <graph_info.h>

Classes

class  Impl
 

Public Member Functions

 GraphInfo (const std::string &graph_name, VertexInfoVector vertex_infos, EdgeInfoVector edge_infos, const std::string &prefix="./", std::shared_ptr< const InfoVersion > version=nullptr, const std::unordered_map< std::string, std::string > &extra_info={})
 Constructs a GraphInfo instance. More...
 
Result< std::shared_ptr< GraphInfo > > AddVertex (std::shared_ptr< VertexInfo > vertex_info) const
 Adds a vertex info to the GraphInfo instance and returns a new GraphInfo. More...
 
Result< std::shared_ptr< GraphInfo > > AddEdge (std::shared_ptr< EdgeInfo > edge_info) const
 Adds an edge info to the GraphInfo instance and returns a new GraphInfo. More...
 
const std::string & GetName () const
 Get the name of the graph. More...
 
const std::string & GetPrefix () const
 Get the absolute path prefix of the chunk files. More...
 
const std::shared_ptr< const InfoVersion > & version () const
 Get the version info of the graph info object. More...
 
const std::unordered_map< std::string, std::string > & GetExtraInfo () const
 Get the extra metadata of the graph info object. More...
 
std::shared_ptr< VertexInfoGetVertexInfo (const std::string &label) const
 Get the vertex info with the given label. More...
 
std::shared_ptr< EdgeInfoGetEdgeInfo (const std::string &src_label, const std::string &edge_label, const std::string &dst_label) const
 Get the edge info with the given source vertex label, edge label, and destination vertex label. More...
 
int GetVertexInfoIndex (const std::string &label) const
 Get the vertex info index with the given label.
 
int GetEdgeInfoIndex (const std::string &src_label, const std::string &edge_label, const std::string &dst_label) const
 Get the edge info index with the given source vertex label, edge label, and destination label.
 
int VertexInfoNum () const
 Get the number of vertex infos.
 
int EdgeInfoNum () const
 Get the number of edge infos.
 
const std::shared_ptr< VertexInfoGetVertexInfoByIndex (int index) const
 Get the vertex info at the specified index. More...
 
const std::shared_ptr< EdgeInfoGetEdgeInfoByIndex (int index) const
 Get the edge info at the specified index. More...
 
const VertexInfoVector & GetVertexInfos () const
 Get the vertex infos of graph info. More...
 
const EdgeInfoVector & GetEdgeInfos () const
 Get the edge infos of graph info. More...
 
Status Save (const std::string &path) const
 
Result< std::string > Dump () const
 
bool IsValidated () const
 

Static Public Member Functions

static Result< std::shared_ptr< GraphInfo > > Load (const std::string &path)
 Loads the input file as a GraphInfo instance. More...
 
static Result< std::shared_ptr< GraphInfo > > Load (const std::string &input, const std::string &relative_path)
 Loads the input string as a GraphInfo instance. More...
 

Detailed Description

GraphInfo is a class to store the graph meta information.

Definition at line 690 of file graph_info.h.

Constructor & Destructor Documentation

◆ GraphInfo()

graphar::GraphInfo::GraphInfo ( const std::string &  graph_name,
VertexInfoVector  vertex_infos,
EdgeInfoVector  edge_infos,
const std::string &  prefix = "./",
std::shared_ptr< const InfoVersion version = nullptr,
const std::unordered_map< std::string, std::string > &  extra_info = {} 
)
explicit

Constructs a GraphInfo instance.

Parameters
graph_nameThe name of the graph.
vertex_infosThe vertex info vector of the graph.
edge_infosThe edge info vector of the graph.
prefixThe absolute path prefix to store chunk files of the graph. Defaults to "./".
versionThe version of the graph info.
extra_infoThe extra metadata of the graph info.

Definition at line 1111 of file graph_info.cc.

Member Function Documentation

◆ AddEdge()

Result< std::shared_ptr< GraphInfo > > graphar::GraphInfo::AddEdge ( std::shared_ptr< EdgeInfo edge_info) const

Adds an edge info to the GraphInfo instance and returns a new GraphInfo.

Parameters
edge_infoThe edge info to add.
Returns
A Status object indicating the success or failure of the operation. Returns InvalidOperation if the edge info is already contained.

Definition at line 1204 of file graph_info.cc.

◆ AddVertex()

Result< std::shared_ptr< GraphInfo > > graphar::GraphInfo::AddVertex ( std::shared_ptr< VertexInfo vertex_info) const

Adds a vertex info to the GraphInfo instance and returns a new GraphInfo.

Parameters
vertex_infoThe vertex info to add.
Returns
A Status object indicating the success or failure of the operation. Returns InvalidOperation if the vertex info is already contained.

Definition at line 1191 of file graph_info.cc.

◆ Dump()

Result< std::string > graphar::GraphInfo::Dump ( ) const

Returns the graph info as a YAML formatted string.

Returns
A Result object containing the YAML string, or a Status object indicating an error.

Definition at line 1257 of file graph_info.cc.

◆ GetEdgeInfo()

std::shared_ptr< EdgeInfo > graphar::GraphInfo::GetEdgeInfo ( const std::string &  src_label,
const std::string &  edge_label,
const std::string &  dst_label 
) const

Get the edge info with the given source vertex label, edge label, and destination vertex label.

Parameters
src_labelThe label of the source vertex.
edge_labelThe label of the edge.
dst_labelThe label of the destination vertex.
Returns
edge info may be nullptr if the label is not found.

Definition at line 1144 of file graph_info.cc.

◆ GetEdgeInfoByIndex()

const std::shared_ptr< EdgeInfo > graphar::GraphInfo::GetEdgeInfoByIndex ( int  index) const

Get the edge info at the specified index.

Parameters
indexThe index of the edge info.
Returns
edge info may be nullptr if the index is out of range.

Definition at line 1174 of file graph_info.cc.

◆ GetEdgeInfos()

const EdgeInfoVector & graphar::GraphInfo::GetEdgeInfos ( ) const

Get the edge infos of graph info.

Returns
edge infos of graph info

Definition at line 1185 of file graph_info.cc.

◆ GetExtraInfo()

const std::unordered_map< std::string, std::string > & graphar::GraphInfo::GetExtraInfo ( ) const

Get the extra metadata of the graph info object.

Returns
The extra metadata of the graph info object.

Definition at line 1129 of file graph_info.cc.

◆ GetName()

const std::string & graphar::GraphInfo::GetName ( ) const

Get the name of the graph.

Returns
The name of the graph.

Definition at line 1121 of file graph_info.cc.

◆ GetPrefix()

const std::string & graphar::GraphInfo::GetPrefix ( ) const

Get the absolute path prefix of the chunk files.

Returns
The absolute path prefix of the chunk files.

Definition at line 1123 of file graph_info.cc.

◆ GetVertexInfo()

std::shared_ptr< VertexInfo > graphar::GraphInfo::GetVertexInfo ( const std::string &  label) const

Get the vertex info with the given label.

Parameters
labelThe label of the vertex.
Returns
vertex info may be nullptr if the label is not found.

Definition at line 1134 of file graph_info.cc.

◆ GetVertexInfoByIndex()

const std::shared_ptr< VertexInfo > graphar::GraphInfo::GetVertexInfoByIndex ( int  index) const

Get the vertex info at the specified index.

Parameters
indexThe index of the vertex info.
Returns
vertex info may be nullptr if the index is out of range.

Definition at line 1166 of file graph_info.cc.

◆ GetVertexInfos()

const VertexInfoVector & graphar::GraphInfo::GetVertexInfos ( ) const

Get the vertex infos of graph info.

Returns
vertex infos of graph info

Definition at line 1181 of file graph_info.cc.

◆ IsValidated()

bool graphar::GraphInfo::IsValidated ( ) const

Returns whether the graph info is validated.

Returns
True if the graph info is valid, False otherwise.

Definition at line 1189 of file graph_info.cc.

◆ Load() [1/2]

Result< std::shared_ptr< GraphInfo > > graphar::GraphInfo::Load ( const std::string &  input,
const std::string &  relative_path 
)
static

Loads the input string as a GraphInfo instance.

Parameters
inputThe YAML content string.
relative_pathThe relative path to access vertex/edge YAML.
Returns
A Result object containing the GraphInfo instance, or a Status object indicating an error.

Definition at line 1244 of file graph_info.cc.

◆ Load() [2/2]

Result< std::shared_ptr< GraphInfo > > graphar::GraphInfo::Load ( const std::string &  path)
static

Loads the input file as a GraphInfo instance.

Parameters
pathThe path of the YAML file.
Returns
A Result object containing the GraphInfo instance, or a Status object indicating an error.

Definition at line 1231 of file graph_info.cc.

◆ Save()

Status graphar::GraphInfo::Save ( const std::string &  path) const

Saves the graph info to a YAML file.

Parameters
pathThe path of the file to save to.
Returns
A Status object indicating success or failure.

Definition at line 1300 of file graph_info.cc.

◆ version()

const std::shared_ptr< const InfoVersion > & graphar::GraphInfo::version ( ) const

Get the version info of the graph info object.

Returns
The version info of the graph info object.

Definition at line 1125 of file graph_info.cc.


The documentation for this class was generated from the following files: