Metall  v0.29
A persistent memory allocator for data-centric analytics
adjacency_list_graph.cpp

This is an example of how to use a adjacency-list graph data structure with Metall.

// Copyright 2019 Lawrence Livermore National Security, LLC and other Metall
// Project Developers. See the top-level COPYRIGHT file for details.
//
// SPDX-License-Identifier: (Apache-2.0 OR MIT)
#include <iostream>
using vid_t = uint64_t;
using adj_list_graph_t =
int main() {
{
// Create a new Metall datastore in "/tmp/dir"
metall::manager manager(metall::create_only, "/tmp/dir");
// Allocate and construct an object in the persistent memory with a name
// "adj_list_graph"
adj_list_graph_t *adj_list_graph =
manager.construct<adj_list_graph_t>("adj_list_graph")(
manager.get_allocator()); // Arguments to the constructor
// Add an edge (1, 2)
adj_list_graph->add_edge(1, 2);
}
{
// Open the existing Metall datastore in "/tmp/dir"
metall::manager manager(metall::open_only, "/tmp/dir");
adj_list_graph_t *adj_list_graph =
manager.find<adj_list_graph_t>("adj_list_graph").first;
// Add another edge
adj_list_graph->add_edge(1, 3);
// Print the edges of vertex 1
for (auto edge = adj_list_graph->edges_begin(1);
edge != adj_list_graph->edges_end(1); ++edge) {
std::cout << "1 " << *edge << std::endl;
}
}
return 0;
}
Simple adjacency-list graph data structure that can take a custom C++ allocator and be stored in pers...
Definition: adjacency_list.hpp:23
A generalized Metall manager class.
Definition: basic_manager.hpp:40
int main()
Definition: jgraph.cpp:24
basic_manager<> manager
Default Metall manager class which is an alias of basic_manager with the default template parameters.
Definition: metall.hpp:34