Visible to Intel only — GUID: GUID-FC33D074-7A29-4C09-A73A-35A593A3192A
Visible to Intel only — GUID: GUID-FC33D074-7A29-4C09-A73A-35A593A3192A
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.
Related types
Aliases is a way to access graph types using shorter notation.
Alias |
Value |
---|---|
graph_allocator<G> |
graph_traits<G>::allocator_type |
graph_user_value_type<G> |
graph_traits<G>::graph_user_value_type |
vertex_user_value_type<G> |
graph_traits<G>::vertex_user_value_type |
edge_user_value_type<G> |
graph_traits<G>::edge_user_value_type |
vertex_type<G> |
graph_traits<G>::vertex_type |
vertex_size_type<G> |
graph_traits<G>::vertex_size_type |
edge_size_type<G> |
graph_traits<G>::edge_size_type |
vertex_edge_size_type<G> |
graph_traits<G>::vertex_edge_size_type |
vertex_outward_edge_size_type<G> |
graph_traits<G>::vertex_outward_edge_size_type |
vertex_edge_iterator_type<G> |
graph_traits<G>::vertex_edge_iterator_type |
const_vertex_edge_iterator_type<G> |
graph_traits<G>::const_vertex_edge_iterator_type |
vertex_edge_range_type<G> |
graph_traits<G>::vertex_edge_range_type |
const_vertex_edge_range_type<G> |
graph_traits<G>::const_vertex_edge_range_type |
const_vertex_outward_edge_range_type<G> |
graph_traits<G>::const_vertex_outward_edge_range_type |
Graph service functions
Any service function has the following pattern:
template <typename Graph>
return_type<Graph> get_[graph_element](const Graph& g, ...);
template<typenameGraph>constexprautoget_vertex_count(constGraph&g)noexcept->vertex_size_type<Graph>
Returns the number of vertices in the graph.
- Template Parameters
-
Graph – Type of the graph.
- Parameters
-
g – Input graph object.
template<typenameGraph>constexprautoget_edge_count(constGraph&g)noexcept->edge_size_type<Graph>
Returns the number of edges in the graph.
- Template Parameters
-
Graph – Type of the graph.
- Parameters
-
g – Input graph object.
template<typenameGraph>constexprautoget_vertex_degree(constGraph&g, vertex_type<Graph>u)->vertex_edge_size_type<Graph>
Returns the degree for the specified vertex.
- Template Parameters
-
Graph – Type of the graph.
- Parameters
-
g – Input graph object.
u – Vertex index.
template<typenameGraph>constexprautoget_vertex_neighbors(constGraph&g, vertex_type<Graph>u)->const_vertex_edge_range_type<Graph>
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<typenameGraph>constexprautoget_vertex_outward_degree(constGraph&g, vertex_type<Graph>u)->vertex_outward_edge_size_type<Graph>
Returns the outward degree for the specified vertex.
- Template Parameters
-
Graph – Type of the graph.
- Parameters
-
g – Input graph object.
u – Vertex index.
template<typenameGraph>constexprautoget_vertex_outward_neighbors(constGraph&g, vertex_type<Graph>u)->const_vertex_outward_edge_range_type<Graph>
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<typenameGraph>constexprautoget_edge_value(constGraph&g, vertex_type<Graph>u, vertex_type<Graph>v)->constedge_user_value_type<Graph>&
Returns the value of an edge (u, v).
- Template Parameters
-
Graph – Type of the graph.
- Parameters
-
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 |
---|---|
get_vertex_count |
|
get_edge_count |
|
get_vertex_degree |
|
get_vertex_outward_degree |
|
get_vertex_neighbors |
|
get_vertex_outward_neighbors |
|
get_edge_value |