3#include <test/csf/Peer.h>
4#include <test/csf/random.h>
151 p->connect(*target, delay);
169 p->disconnect(*target);
205 peer->connect(*to, delay);
235 for (
Peer const* p : t)
266template <
class RandomNumberDistribution,
class Generator>
272 RandomNumberDistribution sizeDist,
275 assert(peers.
size() == ranks.
size());
293template <
class RandomNumberDistribution,
class Generator>
299 RandomNumberDistribution sizeDist,
305 for (
auto& peer : peers)
307 for (
auto& target : groups[u(g)])
308 peer->trust(*target);
316template <
class RandomNumberDistribution,
class Generator>
322 RandomNumberDistribution sizeDist,
329 for (
auto& peer : peers)
331 for (
auto& target : groups[u(g)])
332 peer->connect(*target, delay);
T back_inserter(T... args)
A group of simulation Peers.
peers_type::reference reference
peers_type::const_reference const_reference
friend PeerGroup operator+(PeerGroup const &a, PeerGroup const &b)
const_reference operator[](std::size_t i) const
void connectFromTrust(SimDuration delay)
Establish network connections based on trust relations.
void trust(PeerGroup const &o)
Establish trust.
void disconnect(PeerGroup const &o)
Destroy network connection.
void connect(PeerGroup const &o, SimDuration delay)
Establish network connection.
friend std::ostream & operator<<(std::ostream &o, PeerGroup const &t)
std::vector< Peer * > peers_type
void trustAndConnect(PeerGroup const &o, SimDuration delay)
Establish trust and network connection.
peers_type::iterator iterator
PeerGroup(std::vector< Peer * > &&peers)
const_iterator end() const
bool contains(Peer const *p)
void untrust(PeerGroup const &o)
Revoke trust.
friend PeerGroup operator-(PeerGroup const &a, PeerGroup const &b)
const_iterator begin() const
PeerGroup(std::set< Peer * > const &peers)
peers_type::const_iterator const_iterator
PeerGroup(std::vector< Peer * > const &peers)
SimClock::duration SimDuration
TaggedInteger< std::uint32_t, PeerIDTag > PeerID
std::vector< PeerGroup > randomRankedGroups(PeerGroup &peers, std::vector< double > const &ranks, int numGroups, RandomNumberDistribution sizeDist, Generator &g)
Randomly generate peer groups according to ranks.
void randomRankedConnect(PeerGroup &peers, std::vector< double > const &ranks, int numGroups, RandomNumberDistribution sizeDist, Generator &g, SimDuration delay)
Generate random network groups based on peer rankings.
void randomRankedTrust(PeerGroup &peers, std::vector< double > const &ranks, int numGroups, RandomNumberDistribution sizeDist, Generator &g)
Generate random trust groups based on peer rankings.
std::vector< T > randomWeightedShuffle(std::vector< T > v, std::vector< double > w, G &g)
Return a randomly shuffled copy of vector based on weights w.
Dir::ConstIterator const_iterator
T set_difference(T... args)
A single peer in the simulation.
TrustGraph< Peer * > & trustGraph
Handle to Trust graph of network.