4#include <csf/SimTime.h>
5#include <csf/Validation.h>
162 p->connect(*target, delay);
181 p->disconnect(*target);
218 peer->connect(*to, delay);
248 for (
Peer const* p : t)
279template <
class RandomNumberDistribution,
class Generator>
285 RandomNumberDistribution sizeDist,
288 assert(peers.
size() == ranks.
size());
307template <
class RandomNumberDistribution,
class Generator>
313 RandomNumberDistribution sizeDist,
319 for (
auto& peer : peers)
321 for (
auto& target : groups[u(g)])
322 peer->trust(*target);
331template <
class RandomNumberDistribution,
class Generator>
337 RandomNumberDistribution sizeDist,
344 for (
auto& peer : peers)
346 for (
auto& target : groups[u(g)])
347 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.