GALib-Parallel
Header-only C++ library for parallel evolutionary algorithms
Loading...
Searching...
No Matches
OneWayRingTopology.h
Go to the documentation of this file.
1#ifndef ONE_WAY_RING_TOPOLOGY_H
2#define ONE_WAY_RING_TOPOLOGY_H
3
4#pragma once
5
7
8namespace galib {
9
17 public:
19 explicit OneWayRingTopology(const std::size_t num_nodes) : Topology(num_nodes) {}
20
26 [[nodiscard]] internal::NodeLinks getLinks(const std::size_t node) const override {
27 const std::size_t num_nodes = getNumNodes();
28 return {
29 .neighbors_out = {(node + 1) % num_nodes},
30 .neighbors_in = {(node - 1 + num_nodes) % num_nodes}
31 };
32 }
33 };
34
35}
36
37#endif // ONE_WAY_RING_TOPOLOGY_H
A topology where islands are connected in a unidirectional circle.
internal::NodeLinks getLinks(const std::size_t node) const override
Returns the next node as output and previous node as input.
OneWayRingTopology(const std::size_t num_nodes)
Constructs a unidirectional ring topology for num_nodes nodes.
Abstract base class for archipelago topologies.
Definition Topology.h:28
std::size_t getNumNodes() const
Returns the total number of nodes in the topology.
Definition Topology.h:34