cgv
|
A graph represented in an adjacency list. More...
#include <adjacency_list.h>
Public Types | |
typedef v_type | vertex_type |
typedef v_type::edge_type | edge_type |
Public Member Functions | |
adjacency_list (const unsigned vnum, bool directed=true) | |
creates a graph with vnum vertices and zero edges the graph is directed if the flag directed is true | |
adjacency_list (const adjacency_list &al) | |
copy constructor | |
adjacency_list & | operator= (const adjacency_list &al) |
assignment operator | |
virtual | ~adjacency_list () |
destructor of adjacency_list | |
void | resize (const unsigned &vnum) |
resize number of vertices, all edge data is removed | |
void | clear () |
const unsigned | nverts () const |
return number of vertices | |
void | remove_all_edges () |
removes all edges | |
vertex_type & | vertex (unsigned i) |
access vertex i | |
const vertex_type & | vertex (unsigned i) const |
access const vertex i | |
bool | is_directed () const |
returns true if the graph is a directed one | |
bool | edge_exists (int start, int end) const |
checks if edge is already in list | |
bool | add_edge (const edge_type &e) |
adds an edge to the list definded by the start and end vertex | |
bool | add_edge (unsigned int start, unsigned int end) |
adds an edge to the list definded by the start and end vertex | |
void | add_vertex (const vertex_type &v) |
add new vertex to graph | |
Public Attributes | |
std::vector< vertex_type > * | vertices |
vertices | |
bool | directed |
flag indicating a directed/undirected graph | |
A graph represented in an adjacency list.
To create a basic graph without extra information stored per vertex or edge use the predefined type cgv::math::graph: cgv::math::graph g;
To create a basic weighted graph with an additional weight attribute per edge use the predefined type cgv::math::weighted_graph; cgv::math::weighted_graph wg;
To create a graph with extra attributes per edge and vertex:
struct my_edge: public cgv::math::edge { double my_extra_edge_attr; };
struct my_vertex : public cgv::math::vertex<my_edge> { int my_extra_vertex_attr; };
typedef cgv::math::adjacency_list< my_vertex > my_graph; my_graph g; ...
Definition at line 73 of file adjacency_list.h.
typedef v_type::edge_type cgv::math::adjacency_list< v_type >::edge_type |
Definition at line 77 of file adjacency_list.h.
typedef v_type cgv::math::adjacency_list< v_type >::vertex_type |
Definition at line 76 of file adjacency_list.h.
|
inline |
Definition at line 86 of file adjacency_list.h.
|
inline |
creates a graph with vnum vertices and zero edges the graph is directed if the flag directed is true
Definition at line 94 of file adjacency_list.h.
References cgv::math::adjacency_list< v_type >::directed, and cgv::math::adjacency_list< v_type >::vertices.
|
inline |
copy constructor
Definition at line 103 of file adjacency_list.h.
References cgv::math::adjacency_list< v_type >::directed, cgv::math::adjacency_list< v_type >::is_directed(), and cgv::math::adjacency_list< v_type >::vertices.
|
inlinevirtual |
destructor of adjacency_list
Definition at line 124 of file adjacency_list.h.
References cgv::math::adjacency_list< v_type >::vertices.
|
inline |
adds an edge to the list definded by the start and end vertex
Definition at line 207 of file adjacency_list.h.
References cgv::math::adjacency_list< v_type >::directed, cgv::math::adjacency_list< v_type >::edge_exists(), and cgv::math::adjacency_list< v_type >::nverts().
|
inline |
adds an edge to the list definded by the start and end vertex
Definition at line 235 of file adjacency_list.h.
References cgv::math::adjacency_list< v_type >::directed, cgv::math::adjacency_list< v_type >::edge_exists(), and cgv::math::adjacency_list< v_type >::nverts().
|
inline |
add new vertex to graph
Definition at line 266 of file adjacency_list.h.
References cgv::math::adjacency_list< v_type >::vertices.
|
inline |
Definition at line 143 of file adjacency_list.h.
|
inline |
checks if edge is already in list
Definition at line 191 of file adjacency_list.h.
Referenced by cgv::math::adjacency_list< v_type >::add_edge(), and cgv::math::adjacency_list< v_type >::add_edge().
|
inline |
returns true if the graph is a directed one
Definition at line 184 of file adjacency_list.h.
References cgv::math::adjacency_list< v_type >::directed.
Referenced by cgv::math::adjacency_list< v_type >::adjacency_list(), and cgv::math::adjacency_list< v_type >::operator=().
|
inline |
return number of vertices
Definition at line 154 of file adjacency_list.h.
References cgv::math::adjacency_list< v_type >::vertices.
Referenced by cgv::math::adjacency_list< v_type >::add_edge(), cgv::math::adjacency_list< v_type >::add_edge(), and cgv::math::adjacency_list< v_type >::remove_all_edges().
|
inline |
assignment operator
Definition at line 112 of file adjacency_list.h.
References cgv::math::adjacency_list< v_type >::directed, cgv::math::adjacency_list< v_type >::is_directed(), and cgv::math::adjacency_list< v_type >::vertices.
|
inline |
removes all edges
Definition at line 161 of file adjacency_list.h.
References cgv::math::adjacency_list< v_type >::nverts().
Referenced by cgv::math::adjacency_list< v_type >::resize().
|
inline |
resize number of vertices, all edge data is removed
Definition at line 131 of file adjacency_list.h.
References cgv::math::adjacency_list< v_type >::remove_all_edges(), and cgv::math::adjacency_list< v_type >::vertices.
|
inline |
access vertex i
Definition at line 170 of file adjacency_list.h.
References cgv::math::adjacency_list< v_type >::vertices.
|
inline |
access const vertex i
Definition at line 176 of file adjacency_list.h.
References cgv::math::adjacency_list< v_type >::vertices.
bool cgv::math::adjacency_list< v_type >::directed |
flag indicating a directed/undirected graph
Definition at line 83 of file adjacency_list.h.
Referenced by cgv::math::adjacency_list< v_type >::add_edge(), cgv::math::adjacency_list< v_type >::add_edge(), cgv::math::adjacency_list< v_type >::adjacency_list(), cgv::math::adjacency_list< v_type >::adjacency_list(), cgv::math::adjacency_list< v_type >::is_directed(), and cgv::math::adjacency_list< v_type >::operator=().
std::vector<vertex_type>* cgv::math::adjacency_list< v_type >::vertices |
vertices
Definition at line 81 of file adjacency_list.h.
Referenced by cgv::math::adjacency_list< v_type >::add_vertex(), cgv::math::adjacency_list< v_type >::adjacency_list(), cgv::math::adjacency_list< v_type >::adjacency_list(), cgv::math::adjacency_list< v_type >::nverts(), cgv::math::adjacency_list< v_type >::operator=(), cgv::math::adjacency_list< v_type >::resize(), cgv::math::adjacency_list< v_type >::vertex(), cgv::math::adjacency_list< v_type >::vertex(), and cgv::math::adjacency_list< v_type >::~adjacency_list().