Graph Service#
Programming interface#
All types and functions in this section are declared in the
oneapi::dal::preview namespace and are available via inclusion of the
oneapi/dal/graph/service_functions.hpp header file.
The graph service is a set of functions that allow you to get access to the elements and characteristics of the graph, such as vertex degree or edge attribute.
Graph service functions are defined as function templates with Graph
as a template parameter. Graph service functions introduce aliases
to graph_traits as shown below.
Graph service functions#
Any service function has the following pattern:
template <typename Graph>
return_type<Graph> get_[graph_element](const Graph& g, ...);
-
template<typename Graph>
vertex_size_type<Graph> get_vertex_count(const Graph &g) noexcept# Returns the number of vertices in the graph.
- Template Parameters:
Graph – Type of the graph.
- Parameters:
g – Input graph object.
-
template<typename Graph>
edge_size_type<Graph> get_edge_count(const Graph &g) noexcept# Returns the number of edges in the graph.
- Template Parameters:
Graph – Type of the graph.
- Parameters:
g – Input graph object.
-
template<typename Graph>
vertex_edge_size_type<Graph> get_vertex_degree(const Graph &g, vertex_type<Graph> u)# Returns the degree for the specified vertex.
- Template Parameters:
Graph – Type of the graph.
- Parameters:
g – Input graph object.
u – Vertex index.
-
template<typename Graph>
const_vertex_edge_range_type<Graph> get_vertex_neighbors(const Graph &g, vertex_type<Graph> u)# Returns the range of the vertex neighbors for the specified vertex.
- Template Parameters:
Graph – Type of the graph.
- Parameters:
g – Input graph object.
u – Vertex index.
-
template<typename Graph>
vertex_outward_edge_size_type<Graph> get_vertex_outward_degree(const Graph &g, vertex_type<Graph> u)# Returns the outward degree for the specified vertex.
- Template Parameters:
Graph – Type of the graph.
- Parameters:
g – Input graph object.
u – Vertex index.
-
template<typename Graph>
const_vertex_outward_edge_range_type<Graph> get_vertex_outward_neighbors(const Graph &g, vertex_type<Graph> u)# Returns the range of the vertex outward neighbors for the specified vertex.
- Template Parameters:
Graph – Type of the graph.
- Parameters:
g – Input graph object.
u – Vertex index.
-
template<typename Graph>
const edge_user_value_type<Graph> &get_edge_value(const Graph &g, vertex_type<Graph> u, vertex_type<Graph> v)# Returns the value of an edge (u, v).
- Template Parameters:
Graph – Type of the graph.
- Parameters:
g – Input graph object.
u – Source vertex index.
v – Destination vertex index.
Usage Example#
using graph_type = ...;
const my_graph_type g = ...;
std::cout << "The number of vertices: " << oneapi::dal::preview::get_vertex_count(g) << std::endl;
std::cout << "The number of edges: " << oneapi::dal::preview::get_edge_count(g) << std::endl;
Service functions for supported graphs#
This section contains description of service functions supported for the specified graph types.
Service function |
Valid graph concepts |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|