Connected Components¶
Connected components algorithm receives an undirected graph \(G\) as an input and searches for connected components in \(G\). For each vertex in \(G\), the algorithm returns the label of the component this vertex belongs to. The result of the algorithm is a set of labels for all vertices in \(G\).
Operation |
Computational methods |
Programming Interface |
||
Mathematical formulation¶
Refer to Developer Guide: Connected Components.
Programming Interface¶
All types and functions in this section are declared in the
oneapi::dal::preview::connected_components
namespace and
available via inclusion of the oneapi/dal/algo/connected_components.hpp
header file.
Descriptor¶
-
template<typename
Float
= float, typenameMethod
= method::by_default, typenameTask
= task::by_default, typenameAllocator
= std::allocator<char>>
classdescriptor
¶ - Template Parameters
Float – This parameter is not used for Connected Components algortihm.
Method – Tag-type that specifies the implementation of the algorithm. Can be
method::afforest
.Task – Tag-type that specifies the type of the problem to solve. Can be
task::vertex_partitioning
.Allocator – Custom allocator for all memory management inside the algorithm.
Constructors
-
descriptor
(const Allocator &allocator = std::allocator<char>())¶
Public Methods
-
Allocator
get_allocator
() const¶ Returns a copy of the allocator used in the algorithm for internal memory management.
Task tags¶
-
struct
vertex_partitioning
¶ Tag-type that parameterizes entities that are used for Connected Components algorithm.
-
using
by_default
= vertex_partitioning¶ Alias tag-type for the vertex partitioning task.
Computing preview::vertex_partitioning(...)
¶
Input¶
-
template<typename
Graph
, typenameTask
= task::by_default>
classvertex_partitioning_input
¶ - Template Parameters
Graph – Type of the input graph.
Constructors
-
vertex_partitioning_input
(const Graph &g)¶ Constructs the algorithm input initialized with the graph.
- Parameters
g – The input graph.
Properties
-
const Graph &
graph
¶ Returns the constant reference to the input graph.
- Getter & Setter
const Graph & get_graph() const
auto & set_graph(const Graph &g)
Result¶
-
template<typename
Task
= task::by_default>
classvertex_partitioning_result
¶ Constructors
-
vertex_partitioning_result
()¶ Constructs the empty result.
Properties
-
const table &
labels
¶ The table of size [vertex_count x 1] with computed component ids for each vertex.
- Getter & Setter
const table & get_labels() const
auto & set_labels(const table &value)
-
int64_t
component_count
¶ The number of connected components.
- Getter & Setter
int64_t get_component_count() const
auto & set_component_count(int64_t value)
-
Operation¶
-
template<typename
Graph
, typenameDescriptor
>
connected_components::vertex_partitioning_resultpreview
::
vertex_partitioning
(const Descriptor &desc, const Graph &g)¶ - Parameters
desc – Connected Components algorithm descriptor
connected_components::descriptor
g – Input graph
Examples¶
Batch Processing: