GALib-Parallel
Header-only C++ library for parallel evolutionary algorithms
Loading...
Searching...
No Matches
FullyConnectedTopology.h
Go to the documentation of this file.
1#ifndef FULLY_CONNECTED_TOPOLOGY_H
2#define FULLY_CONNECTED_TOPOLOGY_H
3
4#pragma once
5
7
8namespace galib {
9
17 public:
19 explicit FullyConnectedTopology(const std::size_t num_nodes) : Topology(num_nodes) {}
20
26 internal::NodeLinks getLinks(const std::size_t node) const override {
28 const std::size_t num_nodes = getNumNodes();
29 links.neighbors_out.reserve(num_nodes - 1);
30 links.neighbors_in.reserve(num_nodes - 1);
31
32 for (std::size_t i = 0; i < num_nodes; ++i) {
33 if (i != node) {
34 links.neighbors_out.push_back(i);
35 links.neighbors_in.push_back(i);
36 }
37 }
38
39 return links;
40 }
41
42 };
43
44}
45
46#endif // FULLY_CONNECTED_TOPOLOGY_H
A topology where every island is connected to every other island.
internal::NodeLinks getLinks(const std::size_t node) const override
Returns all nodes (except node) as both input and output neighbors.
FullyConnectedTopology(const std::size_t num_nodes)
Constructs a fully connected 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