cgv
|
#include <adjacency_list.h>
Public Member Functions | |
adjacency_list (const unsigned vnum, bool directed=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 | |
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; ...
|
inline |
creates a graph with vnum vertices and zero edges the graph is directed if the flag directed is true