Undirected graph. More...
#include <graph.hh>
Public Types | |
typedef Graph< void > | category |
typedef std::set< edge_data_t > | edges_set_t |
A set to test the presence of a given edge. | |
typedef std::vector< edge_data_t > | edges_t |
The type of the set of edges. | |
typedef graph | exact_t |
typedef std::vector < vertex_data_t > | vertices_t |
The type of the set of vertices. | |
typedef mln::internal::vertex_fwd_iterator < graph > | vertex_fwd_iter |
Iterator typesVertex iterators. | |
typedef mln::internal::vertex_bkd_iterator < graph > | vertex_bkd_iter |
typedef vertex_fwd_iter | vertex_iter |
typedef mln::internal::vertex_nbh_edge_fwd_iterator < graph > | vertex_nbh_edge_fwd_iter |
Vertex centered edge iterators. | |
typedef mln::internal::vertex_nbh_edge_bkd_iterator < graph > | vertex_nbh_edge_bkd_iter |
typedef vertex_nbh_edge_fwd_iter | vertex_nbh_edge_iter |
typedef mln::internal::vertex_nbh_vertex_fwd_iterator < graph > | vertex_nbh_vertex_fwd_iter |
Vertex centered vertex iterators. | |
typedef mln::internal::vertex_nbh_vertex_bkd_iterator < graph > | vertex_nbh_vertex_bkd_iter |
typedef vertex_nbh_vertex_fwd_iter | vertex_nbh_vertex_iter |
typedef mln::internal::edge_fwd_iterator < graph > | edge_fwd_iter |
Edge iterators. | |
typedef mln::internal::edge_bkd_iterator < graph > | edge_bkd_iter |
typedef edge_fwd_iter | edge_iter |
typedef mln::internal::edge_nbh_edge_fwd_iterator < graph > | edge_nbh_edge_fwd_iter |
Edge centered edge iterators. | |
typedef mln::internal::edge_nbh_edge_bkd_iterator < graph > | edge_nbh_edge_bkd_iter |
typedef edge_nbh_edge_fwd_iter | edge_nbh_edge_iter |
Public Member Functions | |
graph () | |
graph (unsigned nvertices) | |
Construct a graph with nvertices vertices. | |
bool | has_v (const vertex_id_t &id_v) const |
Check whether a vertex id id_v exists in the graph. | |
void | invalidate () |
Invalidate the graph. | |
bool | is_valid () const |
Return true if this graph is valid. | |
void | print_debug (std::ostream &ostr) const |
Print on ostr the graph. | |
edge_id_t | v_ith_nbh_edge (const vertex_id_t &id_v, unsigned i) const |
Returns the i th edge adjacent to the vertex id_v . | |
vertex_id_t | v_ith_nbh_vertex (const vertex_id_t &id_v, unsigned i) const |
Returns the i th vertex adjacent to the vertex id_v . | |
size_t | v_nmax () const |
Return the number of vertices in the graph. | |
size_t | v_nmax_nbh_edges (const vertex_id_t &id_v) const |
Return the number of adjacent edges of vertex id_v . | |
size_t | v_nmax_nbh_vertices (const vertex_id_t &id_v) const |
Return the number of adjacent vertices of vertex id_v . | |
unsigned | add_vertex () |
Vertex oriented. | |
std::pair< vertex_id_t, vertex_id_t > | add_vertices (unsigned n) |
Add n vertices to the graph. | |
vertex_t | vertex (vertex_id_t id_v) const |
Return the vertex whose id is v. | |
edge_id_t | add_edge (const vertex_id_t &id_v1, const vertex_id_t &id_v2) |
Edge oriented. | |
edge_t | edge (const edge_id_t &e) const |
Return the edge whose id is e. | |
const std::vector < util::ord_pair< vertex_id_t > > & | edges () const |
Return the list of all edges. | |
size_t | e_nmax () const |
Return the number of edges in the graph. | |
bool | has_e (const edge_id_t &id_e) const |
Return whether id_e is in the graph. | |
edge_t | edge (const vertex_t &v1, const vertex_t &v2) const |
@} | |
vertex_id_t | v1 (const edge_id_t &id_e) const |
Return the first vertex associated to the edge id_e . | |
vertex_id_t | v2 (const edge_id_t &id_e) const |
Return the second vertex associated to edge id_e . | |
size_t | e_nmax_nbh_edges (const edge_id_t &id_e) const |
Return the number max of adjacent edge, given an edge id_e . | |
edge_id_t | e_ith_nbh_edge (const edge_id_t &id_e, unsigned i) const |
Return the i th edge adjacent to the edge id_e . | |
template<typename G2 > | |
bool | is_subgraph_of (const G2 &g) const |
Return whether this graph is a subgraph Return true if g and *this have the same graph_id. | |
const void * | id () const |
Misc. | |
bool | has (const util::vertex< graph > &v) const |
Vertex oriented methodsCheck whether a vertex v exists in the graph. | |
bool | has (const util::edge< graph > &e) const |
Edge oriented methodsCheck whether an edge e exists in the graph. | |
vertex_id_t | v_other (const edge_id_t &id_e, const vertex_id_t &id_v) const |
Vertex and edge oriented methods. | |
Protected Types | |
typedef util::edge< graph > | edge_t |
The type of an edge. | |
typedef util::vertex< graph > | vertex_t |
The type of a vertex. | |
Protected Attributes | |
util::tracked_ptr < mln::internal::data< graph > > | data_ |
Internal data, sharable by several graphs. | |
Private Types | |
typedef super::edge_data_t | edge_data_t |
Internal edge data type. | |
typedef internal::graph_base < graph > | super |
The super class. | |
typedef super::vertex_data_t | vertex_data_t |
Internal vertex data type. |
Undirected graph.
typedef Graph<void> mln::Graph< graph >::category [inherited] |
Reimplemented from mln::Object< graph >.
typedef super::edge_data_t mln::util::graph::edge_data_t [private] |
Internal edge data type.
Reimplemented from mln::util::internal::graph_base< graph >.
Edge iterators.
Edge centered edge iterators.
typedef util::edge<graph > mln::util::internal::graph_base< graph >::edge_t [protected, inherited] |
The type of an edge.
typedef std::set<edge_data_t> mln::util::graph::edges_set_t |
A set to test the presence of a given edge.
typedef std::vector<edge_data_t> mln::util::graph::edges_t |
The type of the set of edges.
typedef graph mln::Object< graph >::exact_t [inherited] |
typedef internal::graph_base<graph> mln::util::graph::super [private] |
The super class.
typedef super::vertex_data_t mln::util::graph::vertex_data_t [private] |
Internal vertex data type.
Reimplemented from mln::util::internal::graph_base< graph >.
typedef mln::internal::vertex_nbh_edge_bkd_iterator<graph> mln::util::graph::vertex_nbh_edge_bkd_iter |
typedef mln::internal::vertex_nbh_edge_fwd_iterator<graph> mln::util::graph::vertex_nbh_edge_fwd_iter |
Vertex centered edge iterators.
typedef mln::internal::vertex_nbh_vertex_bkd_iterator<graph> mln::util::graph::vertex_nbh_vertex_bkd_iter |
typedef mln::internal::vertex_nbh_vertex_fwd_iterator<graph> mln::util::graph::vertex_nbh_vertex_fwd_iter |
Vertex centered vertex iterators.
typedef util::vertex<graph > mln::util::internal::graph_base< graph >::vertex_t [protected, inherited] |
The type of a vertex.
typedef std::vector<vertex_data_t> mln::util::graph::vertices_t |
The type of the set of vertices.
mln::util::graph::graph | ( | ) | [inline] |
Constructor.
References mln::util::internal::graph_base< graph >::data_.
mln::util::graph::graph | ( | unsigned | nvertices | ) | [inline] |
Construct a graph with nvertices
vertices.
References mln::util::internal::graph_base< graph >::data_.
edge_id_t mln::util::graph::add_edge | ( | const vertex_id_t & | id_v1, | |
const vertex_id_t & | id_v2 | |||
) | [inline] |
Edge oriented.
Add an edge.
mln_max(unsigned)
. References mln::util::internal::graph_base< graph >::data_, edge(), mln::util::ord_pair< T >::first(), has_v(), and mln::util::ord_pair< T >::second().
Referenced by mln::make::impl::generic::influence_zone_adjacency_graph(), mln::make::impl::generic::rag_and_labeled_wsl(), mln::make::impl::generic::region_adjacency_graph(), and mln::make::voronoi().
unsigned mln::util::graph::add_vertex | ( | ) | [inline] |
Vertex oriented.
Shortcuts factoring the insertion of vertices and edges. Add a vertex.
References mln::util::internal::graph_base< graph >::data_, and v_nmax().
Referenced by mln::make::voronoi().
std::pair< vertex_id_t, vertex_id_t > mln::util::graph::add_vertices | ( | unsigned | n | ) | [inline] |
Add n
vertices to the graph.
References mln::util::internal::graph_base< graph >::data_, and v_nmax().
Referenced by mln::make::impl::generic::influence_zone_adjacency_graph(), mln::make::impl::generic::rag_and_labeled_wsl(), and mln::make::impl::generic::region_adjacency_graph().
Return the i
th edge adjacent to the edge id_e
.
References e_nmax(), e_nmax_nbh_edges(), has_e(), v1(), v2(), v_ith_nbh_edge(), and v_nmax_nbh_edges().
size_t mln::util::graph::e_nmax | ( | ) | const [inline] |
Return the number of edges in the graph.
References mln::util::internal::graph_base< graph >::data_.
Referenced by e_ith_nbh_edge(), and edge().
size_t mln::util::graph::e_nmax_nbh_edges | ( | const edge_id_t & | id_e | ) | const [inline] |
Return the number max of adjacent edge, given an edge id_e
.
References has_e(), v1(), v2(), and v_nmax_nbh_edges().
Referenced by e_ith_nbh_edge().
graph::edge_t mln::util::graph::edge | ( | const edge_id_t & | e | ) | const [inline] |
graph::edge_t mln::util::graph::edge | ( | const vertex_t & | v1, | |
const vertex_t & | v2 | |||
) | const [inline] |
@}
Return the corresponding edge id if exists. If it is not, returns an invalid edge.
References mln::util::internal::graph_base< graph >::data_, has_v(), and mln::util::vertex< G >::id().
const std::vector< util::ord_pair< vertex_id_t > > & mln::util::graph::edges | ( | ) | const [inline] |
Return the list of all edges.
References mln::util::internal::graph_base< graph >::data_.
bool mln::util::internal::graph_base< graph >::has | ( | const util::edge< graph > & | e | ) | const [inherited] |
Edge oriented methodsCheck whether an edge e
exists in the graph.
bool mln::util::internal::graph_base< graph >::has | ( | const util::vertex< graph > & | v | ) | const [inherited] |
Vertex oriented methodsCheck whether a vertex v
exists in the graph.
bool mln::util::graph::has_e | ( | const edge_id_t & | id_e | ) | const [inline] |
Return whether id_e
is in the graph.
@{
References mln::util::internal::graph_base< graph >::data_.
Referenced by e_ith_nbh_edge(), e_nmax_nbh_edges(), v1(), and v2().
bool mln::util::graph::has_v | ( | const vertex_id_t & | id_v | ) | const [inline] |
Check whether a vertex id id_v
exists in the graph.
References mln::util::internal::graph_base< graph >::data_.
Referenced by add_edge(), edge(), v_ith_nbh_edge(), v_ith_nbh_vertex(), v_nmax_nbh_edges(), v_nmax_nbh_vertices(), and vertex().
const void* mln::util::internal::graph_base< graph >::id | ( | ) | const [inherited] |
void mln::Graph< graph >::invalidate | ( | ) | [inherited] |
Invalidate the graph.
FIXME: does nothing!
bool mln::util::graph::is_subgraph_of | ( | const G2 & | g | ) | const [inline] |
Return whether this graph is a subgraph Return true if g and *this have the same graph_id.
References mln::util::internal::graph_base< graph >::id().
bool mln::Graph< graph >::is_valid | ( | ) | const [inherited] |
Return true if this graph is valid.
FIXME: currently it always returns true.
void mln::util::internal::graph_base< graph >::print_debug | ( | std::ostream & | ostr | ) | const [inherited] |
Print on ostr
the graph.
[in] | ostr | The output stream. |
vertex_id_t mln::util::graph::v1 | ( | const edge_id_t & | id_e | ) | const [inline] |
Return the first vertex associated to the edge id_e
.
References mln::util::internal::graph_base< graph >::data_, and has_e().
Referenced by e_ith_nbh_edge(), and e_nmax_nbh_edges().
vertex_id_t mln::util::graph::v2 | ( | const edge_id_t & | id_e | ) | const [inline] |
Return the second vertex associated to edge id_e
.
References mln::util::internal::graph_base< graph >::data_, and has_e().
Referenced by e_ith_nbh_edge(), and e_nmax_nbh_edges().
edge_id_t mln::util::graph::v_ith_nbh_edge | ( | const vertex_id_t & | id_v, | |
unsigned | i | |||
) | const [inline] |
Returns the i
th edge adjacent to the vertex id_v
.
References mln::util::internal::graph_base< graph >::data_, has_v(), and v_nmax_nbh_edges().
Referenced by e_ith_nbh_edge(), and v_ith_nbh_vertex().
vertex_id_t mln::util::graph::v_ith_nbh_vertex | ( | const vertex_id_t & | id_v, | |
unsigned | i | |||
) | const [inline] |
Returns the i
th vertex adjacent to the vertex id_v
.
References has_v(), v_ith_nbh_edge(), and mln::util::internal::graph_base< graph >::v_other().
size_t mln::util::graph::v_nmax | ( | ) | const [inline] |
Return the number of vertices in the graph.
References mln::util::internal::graph_base< graph >::data_.
Referenced by add_vertex(), and add_vertices().
size_t mln::util::graph::v_nmax_nbh_edges | ( | const vertex_id_t & | id_v | ) | const [inline] |
Return the number of adjacent edges of vertex id_v
.
References mln::util::internal::graph_base< graph >::data_, and has_v().
Referenced by e_ith_nbh_edge(), e_nmax_nbh_edges(), v_ith_nbh_edge(), and v_nmax_nbh_vertices().
size_t mln::util::graph::v_nmax_nbh_vertices | ( | const vertex_id_t & | id_v | ) | const [inline] |
Return the number of adjacent vertices of vertex id_v
.
References has_v(), and v_nmax_nbh_edges().
vertex_id_t mln::util::internal::graph_base< graph >::v_other | ( | const edge_id_t & | id_e, | |
const vertex_id_t & | id_v | |||
) | const [inherited] |
Vertex and edge oriented methods.
Returns the other adjacent vertex id of a given edge id id_e
.
Referenced by v_ith_nbh_vertex().
graph::vertex_t mln::util::graph::vertex | ( | vertex_id_t | id_v | ) | const [inline] |
Return the vertex whose id is v.
References has_v().
util::tracked_ptr< mln::internal::data<graph > > mln::util::internal::graph_base< graph >::data_ [protected, inherited] |
Internal data, sharable by several graphs.
Referenced by add_edge(), add_vertex(), add_vertices(), e_nmax(), edge(), edges(), graph(), has_e(), has_v(), v1(), v2(), v_ith_nbh_edge(), v_nmax(), and v_nmax_nbh_edges().