3#include <test/csf/Peer.h>
4#include <test/csf/random.h>
154 p->connect(*target, delay);
172 p->disconnect(*target);
206 for (
Peer* to : peer->trustGraph.trustedPeers(peer))
208 peer->connect(*to, delay);
248 for (
Peer const* p : t)
279template <
class RandomNumberDistribution,
class Generator>
285 RandomNumberDistribution sizeDist,
288 assert(peers.
size() == ranks.
size());
306template <
class RandomNumberDistribution,
class Generator>
312 RandomNumberDistribution sizeDist,
318 for (
auto& peer : peers)
320 for (
auto& target : groups[u(g)])
321 peer->trust(*target);
329template <
class RandomNumberDistribution,
class Generator>
335 RandomNumberDistribution sizeDist,
342 for (
auto& peer : peers)
344 for (
auto& target : groups[u(g)])
345 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)
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)
typename SimClock::duration SimDuration
std::vector< PeerGroup > randomRankedGroups(PeerGroup &peers, std::vector< double > const &ranks, int numGroups, RandomNumberDistribution sizeDist, Generator &g)
Randomly generate peer groups according to ranks.
std::vector< T > random_weighted_shuffle(std::vector< T > v, std::vector< double > w, G &g)
Return a randomly shuffled copy of vector based on weights w.
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.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
T set_difference(T... args)
A single peer in the simulation.