GALib-Parallel
Header-only C++ library for parallel evolutionary algorithms
Loading...
Searching...
No Matches
BidirectionalRingTopology.h
Go to the documentation of this file.
1#ifndef BIDIRECTIONAL_RING_TOPOLOGY_H
2#define BIDIRECTIONAL_RING_TOPOLOGY_H
3
4#pragma once
5
7
8namespace galib {
9
17 public:
19 explicit BidirectionalRingTopology(const std::size_t num_nodes) : Topology(num_nodes) {}
20
26 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) % num_nodes, (node + 1) % num_nodes},
30 .neighbors_in = {(node - 1 + num_nodes) % num_nodes, (node + 1) % num_nodes}
31 };
32 }
33 };
34
35}
36
37#endif // BIDIRECTIONAL_RING_TOPOLOGY_H
A topology where islands are connected in a bidirectional circle.
internal::NodeLinks getLinks(const std::size_t node) const override
Returns both adjacent nodes as input and output neighbors.
BidirectionalRingTopology(const std::size_t num_nodes)
Constructs a bidirectional 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