41 #ifndef SHAREDNETWORK_H_
42 #define SHAREDNETWORK_H_
48 #include <boost/unordered_set.hpp>
49 #include <boost/serialization/vector.hpp>
50 #include <boost/serialization/utility.hpp>
51 #include <boost/lexical_cast.hpp>
52 #include <boost/mpi.hpp>
53 #include <boost/ptr_container/ptr_vector.hpp>
56 #include "RepastProcess.h"
58 #include "Utilities.h"
59 #include "SRManager.h"
60 #include "RepastErrors.h"
65 const int NET_SR_PAIR = 2000;
66 const int NET_RECV_PROC = 2001;
67 const int NET_EDGE_UPDATE = 2002;
68 const int NET_EXPORTERS_A = 2003;
69 const int NET_EXPORTERS_B = 2004;
70 const int NET_EXPORT_REQUESTS = 2005;
71 const int NET_EDGE_SYNC = 2006;
72 const int NET_EDGE_REMOVE_SYNC = 2007;
90 template<
typename V,
typename E,
typename Ec,
typename EcM>
94 template<
typename Vertex,
typename Edge,
typename AgentContent,
typename EdgeContent,
typename EdgeManager,
typename AgentCreator>
96 EdgeManager& edgeManager, AgentCreator& creator);
98 template<
typename Vertex,
typename Edge,
typename EdgeContent,
typename EdgeManager>
101 boost::unordered_set<AgentId, HashId> fAgents;
102 std::vector<boost::shared_ptr<E> > sharedEdges;
104 std::map<int, int> senders;
107 std::map<int, std::vector<std::pair<AgentId, AgentId> > > removedEdges;
111 virtual bool addAgent(boost::shared_ptr<V> agent);
112 virtual void removeAgent(V* agent);
114 virtual void doAddEdge(boost::shared_ptr<E> edge);
155 void addEdge(boost::shared_ptr<E> edge);
170 return (e->usesTargetAsMaster() ? e->target()->getId().currentRank() : e->source()->getId().currentRank()) == rank;
176 template<
typename V,
typename E,
typename Ec,
typename EcM>
178 Graph<V, E, Ec, EcM> (name, directed, edgeContentMgr) {
183 template<
typename V,
typename E,
typename Ec,
typename EcM>
185 std::map<int, int>::iterator iter = senders.find(rank);
186 if (iter == senders.end()) {
189 senders[rank] = senders[rank] + 1;
193 template<
typename V,
typename E,
typename Ec,
typename EcM>
195 std::map<int, int>::iterator iter = senders.find(rank);
196 if (iter == senders.end())
throw Repast_Error_30(rank);
198 int val = iter->second;
202 senders[rank] = val - 1;
205 template<
typename V,
typename E,
typename Ec,
typename EcM>
208 if (
id.currentRank() != rank) {
212 return Graph<V, E, Ec, EcM>::addAgent(agent);
215 template<
typename V,
typename E,
typename Ec,
typename EcM>
222 template<
typename V,
typename E,
typename Ec,
typename EcM>
225 if (
id.currentRank() != rank) {
228 Graph<V, E, Ec, EcM>::removeAgent(agent);
230 template<
typename V,
typename E,
typename Ec,
typename EcM>
235 template<
typename V,
typename E,
typename Ec,
typename EcM>