46 #include <boost/unordered_map.hpp>
47 #include <boost/smart_ptr.hpp>
51 template<
typename V,
typename E>
58 template<
typename V,
typename E>
61 return vertex->
item()->getId().hashcode();
69 template<
typename V,
typename E>
71 typename boost::unordered_map<AgentId, Vertex<V, E>*, HashId>::value_type, V*> {
73 return value.second->ptr.get();
84 template<
typename V,
typename E>
93 typedef typename AdjListMap::iterator AdjListMapIterator;
141 virtual void addEdge(Vertex<V, E>* other, boost::shared_ptr<E> edge,
EdgeType type) = 0;
148 virtual void successors(std::vector<V*>& out) = 0;
162 virtual void adjacent(std::vector<V*>& out) = 0;
171 virtual void edges(
EdgeType type, std::vector<boost::shared_ptr<E> >& out) = 0;
192 boost::shared_ptr<V>
item()
const {
198 boost::shared_ptr<V> ptr;
200 void getItems(
AdjListMap *adjMap, std::vector<V*>& out);
201 void edges(
AdjListMap *adjMap, std::vector<boost::shared_ptr<E> >& out);
204 template<
typename V,
typename E>
209 template<
typename V,
typename E>
211 boost::shared_ptr<E> ret;
212 AdjListMapIterator iter = adjMap->find(other);
213 if (iter != adjMap->end()) {
220 template<
typename V,
typename E>
221 void Vertex<V, E>::getItems(AdjListMap *adjMap, std::vector<V*>& out) {
222 const AdjListMapIterator iterEnd = adjMap->end();
223 for (AdjListMapIterator iter = adjMap->begin(); iter != iterEnd; ++iter) {
224 out.push_back(iter->first->item().get());
228 template<
typename V,
typename E>
230 const AdjListMapIterator mapEnd = adjMap->end();
231 for (AdjListMapIterator iter = adjMap->begin(); iter != mapEnd; ++iter) {
232 out.push_back(iter->second);
virtual boost::shared_ptr< E > removeEdge(Vertex *other, EdgeType type)=0
Removes the edge of the specified type between this Vertex and the specified Vertex.
virtual void edges(EdgeType type, std::vector< boost::shared_ptr< E > > &out)=0
Gets all the edges of the specified type in which this Vertex participates and return them in out.
virtual void addEdge(Vertex< V, E > *other, boost::shared_ptr< E > edge, EdgeType type)=0
Adds an edge of the specified type between this Vertex and the specified vertex.
Vertex(boost::shared_ptr< V > item)
Creates a Vertex that contains the specified item.
Definition: Vertex.h:205
Agent identity information.
Definition: AgentId.h:60
virtual void predecessors(std::vector< V * > &out)=0
Gets the predecessors of this Vertex.
virtual void adjacent(std::vector< V * > &out)=0
Gets the Vertices adjacent to this Vertex.
Hashes a Vertex using the hashcode of the AgentId that the vertex contains.
Definition: Vertex.h:59
virtual int outDegree()=0
Gets the out degree of this Vertex.
Used internally by repast graphs / networks to encapsulate Vertices.
Definition: Vertex.h:52
virtual void successors(std::vector< V * > &out)=0
Gets the successors of this Vertex.
Unary function used in the transform_iterator that allows an iterator over the vertex map to return t...
Definition: Vertex.h:70
boost::unordered_map< Vertex< V, E > *, boost::shared_ptr< E >, HashVertex< V, E > > AdjListMap
Typedef for the adjacency list map that contains the other Vertices that this Vertex links to.
Definition: Vertex.h:92
virtual boost::shared_ptr< E > findEdge(Vertex *other, EdgeType type)=0
Finds the edge of the specified type between this Vertex and the specified vertex.
boost::shared_ptr< V > item() const
Gets the item that this Vertex contains.
Definition: Vertex.h:192
EdgeType
Enum the identifies whether an edge is incoming or outgoing.
Definition: Vertex.h:98
operator() implementation that returns the hashcode of an AgentId.
Definition: AgentId.h:185
virtual int inDegree()=0
Gets the in degree of this Vertex.