Menge
Modular Pedestrian Simulation Framework for Research and Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GraphVertex.h
Go to the documentation of this file.
1 /*
2 
3 License
4 
5 Menge
6 Copyright © and trademark ™ 2012-14 University of North Carolina at Chapel Hill.
7 All rights reserved.
8 
9 Permission to use, copy, modify, and distribute this software and its documentation
10 for educational, research, and non-profit purposes, without fee, and without a
11 written agreement is hereby granted, provided that the above copyright notice,
12 this paragraph, and the following four paragraphs appear in all copies.
13 
14 This software program and documentation are copyrighted by the University of North
15 Carolina at Chapel Hill. The software program and documentation are supplied "as is,"
16 without any accompanying services from the University of North Carolina at Chapel
17 Hill or the authors. The University of North Carolina at Chapel Hill and the
18 authors do not warrant that the operation of the program will be uninterrupted
19 or error-free. The end-user understands that the program was developed for research
20 purposes and is advised not to rely exclusively on the program for any reason.
21 
22 IN NO EVENT SHALL THE UNIVERSITY OF NORTH CAROLINA AT CHAPEL HILL OR THE AUTHORS
23 BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
24 DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
25 DOCUMENTATION, EVEN IF THE UNIVERSITY OF NORTH CAROLINA AT CHAPEL HILL OR THE
26 AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 
28 THE UNIVERSITY OF NORTH CAROLINA AT CHAPEL HILL AND THE AUTHORS SPECIFICALLY
29 DISCLAIM ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
30 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE AND ANY STATUTORY WARRANTY
31 OF NON-INFRINGEMENT. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND
32 THE UNIVERSITY OF NORTH CAROLINA AT CHAPEL HILL AND THE AUTHORS HAVE NO OBLIGATIONS
33 TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
34 
35 Any questions or comments should be sent to the authors {menge,geom}@cs.unc.edu
36 
37 */
38 
45 #ifndef __GRAPH_VERTEX_H__
46 #define __GRAPH_VERTEX_H__
47 
48 #include "mengeCommon.h"
49 #include "GraphEdge.h"
50 
51 namespace Menge {
52 
56  class GraphVertex {
57  public:
61  GraphVertex();
62 
66  ~GraphVertex();
67 
71  GraphVertex & operator=( const GraphVertex & n );
72 
81  float getDistance( const GraphVertex & other ) { return abs( _pos - other._pos ); }
82 
89  float getDistance( size_t i ) const;
90 
96  void setID( size_t id ) { _id = id; }
97 
101  size_t getID() const { return _id; }
102 
108  inline void setPosition( const Vector2 & p ) { _pos.set( p ); }
109 
115  Vector2 getPosition() const { return _pos; }
116 
123  void setEdge( const GraphEdge & edge, size_t i );
124 
128  size_t getNeighborCount() const { return _edgeCount; }
129 
138  const GraphVertex * getNeighbor( size_t i ) const;
139 
146  void setDegree( size_t degree );
147 
153  size_t getEdgeCount() const { return _edgeCount; }
154 
161  GraphEdge & getEdge( size_t i ) { return _edges[ i ]; }
162 
169  const GraphEdge & getEdge( size_t i ) const { return _edges[ i ]; }
170 
171  protected:
172 
177 
181  size_t _edgeCount;
182 
187 
191  size_t _id;
192  };
193 
194 } // namespace Menge
195 #endif // __GRAPH_VERTEX_H__
196 
197 
GraphEdge * _edges
An array of edges connecting to other vertices.
Definition: GraphVertex.h:176
GraphVertex & operator=(const GraphVertex &n)
Assignment operator.
Definition: GraphVertex.cpp:62
void setPosition(const Vector2 &p)
Sets the graph vertex's position.
Definition: GraphVertex.h:108
The core namespace. All elements of Menge are contained in this namespace.
Definition: AgentGenerator.cpp:43
float getDistance(const GraphVertex &other)
Computes the distance between this vertex and the given vertex.
Definition: GraphVertex.h:81
size_t _id
The identifier for this vertex.
Definition: GraphVertex.h:191
void setEdge(const GraphEdge &edge, size_t i)
Sets the ith edge for the vertex.
Definition: GraphVertex.cpp:89
A graph edge.
Definition: GraphEdge.h:58
void set(Type x, Type y)
Set the x- and y-values from scalar values.
Definition: Vector2.h:121
Vector2 _pos
The position of this vertex.
Definition: GraphVertex.h:186
size_t getID() const
Retrive the identifier for this node.
Definition: GraphVertex.h:101
const GraphEdge & getEdge(size_t i) const
Retrieves a const pointer to the ith edge connected to this node.
Definition: GraphVertex.h:169
const GraphVertex * getNeighbor(size_t i) const
Returns a pointer to the ith neighbor.
Definition: GraphVertex.cpp:96
size_t getEdgeCount() const
Reports the number of edges on the node.
Definition: GraphVertex.h:153
~GraphVertex()
Destructor.
Definition: GraphVertex.cpp:54
A graph vertex.
Definition: GraphVertex.h:56
GraphEdge & getEdge(size_t i)
Retrieves the ith edge connected to this node.
Definition: GraphVertex.h:161
GraphVertex()
Constructor.
Definition: GraphVertex.cpp:49
The definition of a graph edge for performing graph searches and path planning.
void setID(size_t id)
Sets the node identifier.
Definition: GraphVertex.h:96
Vector2 getPosition() const
Reports the position of the vertex.
Definition: GraphVertex.h:115
void setDegree(size_t degree)
Sets the degree – the number of neighbors this vertex has.
Definition: GraphVertex.cpp:103
size_t _edgeCount
The number of edges connecting to this vertex.
Definition: GraphVertex.h:181
size_t getNeighborCount() const
Reports the number of vertices adjacent to this vertex.
Definition: GraphVertex.h:128