@@ -29,37 +29,36 @@ int main(int argc, char* argv[]) {
2929 // read file and construct graph info
3030 std::string path =
3131 TEST_DATA_DIR + " /ldbc_sample/parquet/ldbc_sample.graph.yml" ;
32- auto graph_info = GAR_NAMESPACE ::GraphInfo::Load (path).value ();
32+ auto graph_info = graphar ::GraphInfo::Load (path).value ();
3333
3434 // get the person vertices of graph
3535 std::string label = " person" ;
3636 ASSERT (graph_info->GetVertexInfo (label) != nullptr );
37- auto maybe_vertices =
38- GAR_NAMESPACE::VerticesCollection::Make (graph_info, label);
37+ auto maybe_vertices = graphar::VerticesCollection::Make (graph_info, label);
3938 ASSERT (maybe_vertices.status ().ok ());
4039 auto vertices = maybe_vertices.value ();
4140 int num_vertices = vertices->size ();
4241 std::cout << " num_vertices: " << num_vertices << std::endl;
4342
4443 // get the "person_knows_person" edges of graph
4544 std::string src_label = " person" , edge_label = " knows" , dst_label = " person" ;
46- auto maybe_edges = GAR_NAMESPACE ::EdgesCollection::Make (
45+ auto maybe_edges = graphar ::EdgesCollection::Make (
4746 graph_info, src_label, edge_label, dst_label,
48- GAR_NAMESPACE ::AdjListType::unordered_by_source);
47+ graphar ::AdjListType::unordered_by_source);
4948 ASSERT (!maybe_edges.has_error ());
5049 auto & edges = maybe_edges.value ();
5150
5251 // run bfs algorithm
53- GAR_NAMESPACE ::IdType root = 0 ;
52+ graphar ::IdType root = 0 ;
5453 std::vector<int32_t > distance (num_vertices);
55- std::vector<GAR_NAMESPACE ::IdType> pre (num_vertices);
56- for (GAR_NAMESPACE ::IdType i = 0 ; i < num_vertices; i++) {
54+ std::vector<graphar ::IdType> pre (num_vertices);
55+ for (graphar ::IdType i = 0 ; i < num_vertices; i++) {
5756 distance[i] = (i == root ? 0 : -1 );
5857 pre [i] = (i == root ? root : -1 );
5958 }
6059 auto it_begin = edges->begin (), it_end = edges->end ();
6160 for (int iter = 0 ;; iter++) {
62- GAR_NAMESPACE ::IdType count = 0 ;
61+ graphar ::IdType count = 0 ;
6362 for (auto it = it_begin; it != it_end; ++it) {
6463 auto src = it.source (), dst = it.destination ();
6564 if (distance[src] == iter && distance[dst] == -1 ) {
@@ -80,11 +79,11 @@ int main(int argc, char* argv[]) {
8079 // Append the bfs result to the vertex info as a property group
8180 // and write to file
8281 // construct property group
83- GAR_NAMESPACE ::Property bfs (" bfs" , GAR_NAMESPACE ::int32 (), false );
84- GAR_NAMESPACE ::Property father (" father" , GAR_NAMESPACE ::int64 (), false );
85- std::vector<GAR_NAMESPACE ::Property> property_vector = {bfs, father};
86- auto group = GAR_NAMESPACE::CreatePropertyGroup (property_vector,
87- GAR_NAMESPACE ::FileType::CSV);
82+ graphar ::Property bfs (" bfs" , graphar ::int32 (), false );
83+ graphar ::Property father (" father" , graphar ::int64 (), false );
84+ std::vector<graphar ::Property> property_vector = {bfs, father};
85+ auto group =
86+ graphar::CreatePropertyGroup (property_vector, graphar ::FileType::CSV);
8887
8988 // extend the vertex_info
9089 auto vertex_info = graph_info->GetVertexInfo (label);
@@ -97,15 +96,14 @@ int main(int argc, char* argv[]) {
9796 ASSERT (extend_info->Dump ().status ().ok ());
9897 ASSERT (extend_info->Save (" /tmp/person-new-bfs-father.vertex.yml" ).ok ());
9998 // construct vertex property writer
100- GAR_NAMESPACE ::VertexPropertyWriter writer (extend_info, " file:///tmp/" );
99+ graphar ::VertexPropertyWriter writer (extend_info, " file:///tmp/" );
101100 // convert results to arrow::Table
102101 std::vector<std::shared_ptr<arrow::Array>> arrays;
103102 std::vector<std::shared_ptr<arrow::Field>> schema_vector;
104103 schema_vector.push_back (arrow::field (
105- bfs.name , GAR_NAMESPACE ::DataType::DataTypeToArrowDataType (bfs.type )));
104+ bfs.name , graphar ::DataType::DataTypeToArrowDataType (bfs.type )));
106105 schema_vector.push_back (arrow::field (
107- father.name ,
108- GAR_NAMESPACE::DataType::DataTypeToArrowDataType (father.type )));
106+ father.name , graphar::DataType::DataTypeToArrowDataType (father.type )));
109107 arrow::Int32Builder array_builder1;
110108 ASSERT (array_builder1.Reserve (num_vertices).ok ());
111109 ASSERT (array_builder1.AppendValues (distance).ok ());
@@ -137,24 +135,23 @@ int main(int argc, char* argv[]) {
137135 dst_label = " person" ;
138136 int edge_chunk_size = 1024 , src_chunk_size = 100 , dst_chunk_size = 100 ;
139137 bool directed = true ;
140- auto version = GAR_NAMESPACE::InfoVersion::Parse (" gar/v1" ).value ();
141- auto al = GAR_NAMESPACE::CreateAdjacentList (
142- GAR_NAMESPACE::AdjListType::ordered_by_source,
143- GAR_NAMESPACE::FileType::CSV);
144- auto new_edge_info = GAR_NAMESPACE::CreateEdgeInfo (
138+ auto version = graphar::InfoVersion::Parse (" gar/v1" ).value ();
139+ auto al = graphar::CreateAdjacentList (graphar::AdjListType::ordered_by_source,
140+ graphar::FileType::CSV);
141+ auto new_edge_info = graphar::CreateEdgeInfo (
145142 src_label, edge_label, dst_label, edge_chunk_size, src_chunk_size,
146143 dst_chunk_size, directed, {al}, {}, " " , version);
147144 ASSERT (new_edge_info->IsValidated ());
148145 // save & dump
149146 ASSERT (!new_edge_info->Dump ().has_error ());
150147 ASSERT (new_edge_info->Save (" /tmp/person_bfs_person.edge.yml" ).ok ());
151- GAR_NAMESPACE ::builder::EdgesBuilder edges_builder (
152- new_edge_info, " file:///tmp/" ,
153- GAR_NAMESPACE::AdjListType::ordered_by_source, num_vertices);
148+ graphar ::builder::EdgesBuilder edges_builder (
149+ new_edge_info, " file:///tmp/" , graphar::AdjListType::ordered_by_source,
150+ num_vertices);
154151 for (int i = 0 ; i < num_vertices; i++) {
155152 if (i == root || pre [i] == -1 )
156153 continue ;
157- GAR_NAMESPACE ::builder::Edge e (pre [i], i);
154+ graphar ::builder::Edge e (pre [i], i);
158155 ASSERT (edges_builder.AddEdge (e).ok ());
159156 }
160157 ASSERT (edges_builder.Dump ().ok ());
0 commit comments