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::vector< std::string > &labels={}, 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::vector< std::string > & GetLabels () const
 Get the vertex labels 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 &type) const
 Get the vertex info with the given type. More...
 
std::shared_ptr< EdgeInfoGetEdgeInfo (const std::string &src_type, const std::string &edge_type, const std::string &dst_type) const
 Get the edge info with the given source vertex type, edge type, and destination vertex type. More...
 
int GetVertexInfoIndex (const std::string &type) const
 Get the vertex info index with the given type.
 
int GetEdgeInfoIndex (const std::string &src_type, const std::string &edge_type, const std::string &dst_type) const
 Get the edge info index with the given source vertex type, edge type, and destination type.
 
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 706 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::vector< std::string > &  labels = {},
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.
labelsThe vertex labels 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 1184 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 1281 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 1268 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 1334 of file graph_info.cc.

◆ GetEdgeInfo()

std::shared_ptr< EdgeInfo > graphar::GraphInfo::GetEdgeInfo ( const std::string &  src_type,
const std::string &  edge_type,
const std::string &  dst_type 
) const

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

Parameters
src_typeThe type of the source vertex.
edge_typeThe type of the edge.
dst_typeThe type of the destination vertex.
Returns
edge info may be nullptr if the type is not found.

Definition at line 1221 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 1251 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 1262 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 1206 of file graph_info.cc.

◆ GetLabels()

const std::vector< std::string > & graphar::GraphInfo::GetLabels ( ) const

Get the vertex labels of the graph.

Returns
The vertex labels of the graph.

Definition at line 1196 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 1194 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 1200 of file graph_info.cc.

◆ GetVertexInfo()

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

Get the vertex info with the given type.

Parameters
typeThe type of the vertex.
Returns
vertex info may be nullptr if the type is not found.

Definition at line 1211 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 1243 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 1258 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 1266 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 1321 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 1308 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 1384 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 1202 of file graph_info.cc.


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