18 struct weighted_edge :
public edge
25 weighted_edge() : weight(1.0) {}
26 weighted_edge(
double w) : weight(w) {}
30 template <
typename ET>
33 typedef typename ET edge_type;
35 std::vector<edge_type> edges;
72 template<
typename v_type >
76 typedef typename v_type vertex_type;
77 typedef typename v_type::edge_type edge_type;
96 vertices =
new std::vector<vertex_type>(vnum);
134 vertices =
new std::vector<vertex_type>(vnum);
163 for(
unsigned vi = 0; vi <
nverts(); vi++)
176 const vertex_type&
vertex(
unsigned i)
const
193 for (
unsigned i=0; i <
vertex(start).edges.size(); i++)
195 if(
vertex(start).edges[i].end == end)
219 (*vertices)[e.start].edges.push_back(e);
226 (*vertices)[e.end].edges.push_back(e2);
235 bool add_edge(
unsigned int start,
unsigned int end)
242 if( start <
nverts() && end < vertices->size())
250 (*vertices)[start].edges.push_back(e);
258 (*vertices)[end].edges.push_back(e2);
405 typedef adjacency_list<vertex<edge> > base_graph;
406 typedef adjacency_list<vertex<weighted_edge> > weighted_graph;
const unsigned nverts() const
return number of vertices
Definition: adjacency_list.h:154
bool add_edge(unsigned int start, unsigned int end)
adds an edge to the list definded by the start and end vertex
Definition: adjacency_list.h:235
void remove_all_edges()
removes all edges
Definition: adjacency_list.h:161
bool add_edge(const edge_type &e)
adds an edge to the list definded by the start and end vertex
Definition: adjacency_list.h:207
adjacency_list & operator=(const adjacency_list &al)
assignment operator
Definition: adjacency_list.h:112
adjacency_list(const unsigned vnum, bool directed=true)
Definition: adjacency_list.h:94
bool edge_exists(int start, int end) const
checks if edge is already in list
Definition: adjacency_list.h:191
std::vector< vertex_type > * vertices
vertices
Definition: adjacency_list.h:81
void add_vertex(const vertex_type &v)
add new vertex to graph
Definition: adjacency_list.h:266
bool directed
flag indicating a directed/undirected graph
Definition: adjacency_list.h:83
const vertex_type & vertex(unsigned i) const
access const vertex i
Definition: adjacency_list.h:176
vertex_type & vertex(unsigned i)
access vertex i
Definition: adjacency_list.h:170
adjacency_list(const adjacency_list &al)
copy constructor
Definition: adjacency_list.h:103
Definition: adjacency_list.h:74
virtual ~adjacency_list()
destructor of adjacency_list
Definition: adjacency_list.h:124
the cgv namespace
Definition: vr_calib.cxx:9
void resize(const unsigned &vnum)
resize number of vertices, all edge data is removed
Definition: adjacency_list.h:131
bool is_directed() const
returns true if the graph is a directed one
Definition: adjacency_list.h:184