This is an example of how to use the jgraph.
#include <iostream>
#include <string>
R"({"type":"node", "id":"0", "properties":["user0"]})",
R"({"type":"node", "id":"1", "properties":["user1"]})",
R"({"type":"node", "id":"2", "properties":["item0"]})",
R"({"type":"node", "id":"3", "properties":["item1"]})",
R"({"type":"relationship", "id":"0", "start":"0", "end":"2", "properties":["buy"]})",
R"({"type":"relationship", "id":"1", "start":"1", "end":"3", "properties":["sell"]})",
R"({"type":"relationship", "id":"2", "start":"0", "end":"1", "properties":["friend"]})",
R"({"type":"relationship", "id":"3", "start":"0", "end":"1", "properties":["customer"]})"};
{
std::cout << "-- Create ---" << std::endl;
if (value.as_object()["type"].as_string() == "node") {
const auto &
vertex_id = value.as_object()[
"id"].as_string();
} else if (value.as_object()["type"].as_string() == "relationship") {
const auto &
src_id = value.as_object()[
"start"].as_string();
const auto &
dst_id = value.as_object()[
"end"].as_string();
}
}
std::cout <<
"#of vertices: " <<
graph->num_vertices() << std::endl;
std::cout <<
"#of edges: " <<
graph->num_edges() << std::endl;
}
{
std::cout << "\n--- Open ---" << std::endl;
const auto *
const graph =
std::cout << "<Vertices>" << std::endl;
std::cout << "\n<Edges>" << std::endl;
std::cout <<
"Source vertex ID = " <<
eitr->source_id() << std::endl;
std::cout <<
"Destination vertex ID = " <<
eitr->destination_id()
<< std::endl;
} else {
std::cout <<
"Source vertex ID = " <<
eitr->destination_id()
<< std::endl;
std::cout <<
"Destination vertex ID = " <<
eitr->source_id()
<< std::endl;
}
}
std::cout << std::endl;
}
}
return 0;
}
jgraph::jgraph< metall::manager::allocator_type< std::byte > > graph_type
Definition jgraph.cpp:12
std::vector< std::string > input_json_string_list
Definition jgraph.cpp:14
int main()
Definition jgraph.cpp:24