Developer Guide and Reference

  • 2021.4
  • 09/27/2021
  • Public Content
Contents

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<typename
Graph
>
constexpr
auto
get_vertex_count
(
const
Graph &
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<typename
Graph
>
constexpr
auto
get_edge_count
(
const
Graph &
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<typename
Graph
>
constexpr
auto
get_vertex_degree
(
const
Graph &
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<typename
Graph
>
constexpr
auto
get_vertex_neighbors
(
const
Graph &
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<typename
Graph
>
constexpr
auto
get_vertex_outward_degree
(
const
Graph &
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<typename
Graph
>
constexpr
auto
get_vertex_outward_neighbors
(
const
Graph &
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<typename
Graph
>
constexpr
auto
get_edge_value
(
const
Graph &
g
, vertex_type<Graph>
u
, vertex_type<Graph>
v
) ->
const
edge_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
get_vertex_count
get_edge_count
get_vertex_degree
get_vertex_outward_degree
get_vertex_neighbors
get_vertex_outward_neighbors
get_edge_value

Product and Performance Information

1

Performance varies by use, configuration and other factors. Learn more at www.Intel.com/PerformanceIndex.