BidirectionalGraph
The BidirectionalGraph concept refines IncidenceGraph and adds the
requirement for efficient access to the in-edges of each vertex. This
concept is separated from IncidenceGraph because for directed
graphs efficient access to in-edges typically requires more storage
space, and many algorithms do not require access to in-edges. For
undirected graphs this is not an issue, since the in_edges()
and out_edges() functions are the same, they both return the
edges incident to the vertex.
Refinement of
IncidenceGraph
Notation
| G |
A type that is a model of Graph. |
| g |
An object of type G. |
| v |
An object of type boost::graph_traits<G>::vertex_descriptor. |
Associated Types
| In-Edge Iterator Type |
boost::graph_traits<G>::in_edge_iterator |
An in-edge iterator for a vertex v provides access to the
in-edges of v. As such, the value type of an in-edge iterator
is the edge descriptor type of its graph. An in-edge iterator must
meet the requirements of MultiPassInputIterator.
|
Valid Expressions
| Name | Expression | Return Type | Description |
| In-Edges of a Vertex |
in_edges(v, g) |
std::pair<in_edge_iterator, in_edge_iterator> |
Returns an iterator-range providing access to the
in-edges (for directed graphs) or incident edges (for
undirected graphs) of vertex v in graph g.
|
| In-degree of a Vertex |
in_degree(v, g) |
degree_size_type |
Returns the number of in-edges (for directed graphs) or the
number of incident edges (for undirected graphs) of vertex v
in graph g.
|
| Degree of a Vertex |
degree(v, g) |
degree_size_type |
Returns the number of in-edges plus out-edges (for directed graphs) or the
number of incident edges (for undirected graphs) of vertex v
in graph g.
|
Models
- adjacency_list with Directed=bidirectionalS
- adjacency_list with Directed=undirectedS
Complexity guarantees
The in_edges() function is required to be constant time. The
in_degree() and degree() functions must be linear in
the number of in-edges (for directed graphs) or incident edges (for
undirected graphs).
See Also
Graph concepts
Concept Checking Class
template <class G>
struct BidirectionalGraph_concept
{
typedef typename boost::graph_traits<G>::in_edge_iterator
in_edge_iterator;
void constraints() {
REQUIRE(G, IncidenceGraph);
REQUIRE(in_edge_iterator, MultiPassInputIterator);
p = in_edges(v, g);
e = *p.first;
const_constraints(g);
}
void const_constraints(const G& g) {
p = in_edges(v, g);
e = *p.first;
}
std::pair<in_edge_iterator, in_edge_iterator> p;
typename boost::graph_traits<G>::vertex_descriptor v;
typename boost::graph_traits<G>::edge_descriptor e;
G g;
};