Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world.

```adjacency_matrix<Directed, VertexProperty, EdgeProperty, GraphProperty, Allocator> ```

The adjacency_matrix class implements the BGL graph interface using the traditional adjacency matrix storage format. For a graph with V vertices, a V x V matrix is used, where each element aij is a boolean flag that says whether there is an edge from vertex i to vertex j. Figure 1 shows the adjacency matrix representation of a graph.

Example

Creating the graph of Figure 1.
```  enum { A, B, C, D, E, F, N };
const char* name = "ABCDEF";

Graph g(N);

std::cout << "vertex set: ";
boost::print_vertices(g, name);
std::cout << std::endl;

std::cout << "edge set: ";
boost::print_edges(g, name);
std::cout << std::endl;

std::cout << "out-edges: " << std::endl;
boost::print_graph(g, name);
std::cout << std::endl;
```
The output is:
```  vertex set: A B C D E F

edge set: (B,C) (B,F) (C,A) (C,C) (D,E) (E,D) (F,A)

out-edges:
A -->
B --> C F
C --> A C
D --> E
E --> D
F --> A
```
Creating the graph of Figure 2.
```  enum { A, B, C, D, E, F, N };
const char* name = "ABCDEF";

UGraph ug(N);

std::cout << "vertex set: ";
boost::print_vertices(ug, name);
std::cout << std::endl;

std::cout << "edge set: ";
boost::print_edges(ug, name);
std::cout << std::endl;

std::cout << "incident edges: " << std::endl;
boost::print_graph(ug, name);
std::cout << std::endl;
```
The output is:
```  vertex set: A B C D E F

edge set: (C,A) (C,B) (E,D) (F,A) (F,B)

incident edges:
A <--> C F
B <--> C F
C <--> A B
D <--> E
E <--> D
F <--> A B
```

Template Parameters

ParameterDescriptionDefault
Directed A selector to choose whether the graph is directed or undirected. The options are directedS and undirectedS. directedS
VertexProperty for specifying internal property storage. no_property
EdgeProperty for specifying internal property storage. no_property
GraphProperty for specifying property storage for the graph object. no_property

Model Of

VertexAndEdgeListGraph, Incidence Graph, Bidirectional Graph, AdjacencyMatrix, MutablePropertyGraph, CopyConstructible, and Assignable.

Associated Types

The type for the vertex descriptors associated with the adjacency_matrix.
(Required by Graph.)

The type for the edge descriptors associated with the adjacency_matrix.
(Required by Graph.)

The type for the iterators returned by vertices(). The vertex iterator models RandomAccessIterator.
(Required by VertexListGraph.)

The type for the iterators returned by edges(). This iterator models MultiPassInputIterator.
(Required by EdgeListGraph.)

The type for the iterators returned by out_edges(). This iterator models MultiPassInputIterator.
(Required by IncidenceGraph.)

The type for the iterators returned by in_edges(). This iterator models MultiPassInputIterator.
(Required by BidirectionalGraph.)

The type for the iterators returned by adjacent_vertices(). This iterator models the same concept as the out-edge iterator.

Provides information about whether the graph is directed (directed_tag) or undirected (undirected_tag).
(Required by Graph.)

An adjacency matrix does not allow the insertion of parallel edges, so this type is always disallow_parallel_edge_tag.
(Required by Graph.)

The type used for dealing with the number of vertices in the graph.
(Required by VertexListGraph.)

The type used for dealing with the number of edges in the graph.
(Required by EdgeListGraph.)

The type used for dealing with the number of out-edges of a vertex.
(Required by IncidenceGraph.)

The map type for vertex or edge properties in the graph. The specific property is specified by the PropertyTag template argument, and must match one of the properties specified in the VertexProperty or EdgeProperty for the graph.
(Required by PropertyGraph.)

Member Functions

```adjacency_matrix(vertices_size_type n,
const GraphProperty& p = GraphProperty())
```
Creates a graph object with n vertices and zero edges.
(Required by MutableGraph.)
```template <typename EdgeIterator>
EdgeIterator last,
vertices_size_type n,
const GraphProperty& p = GraphProperty())
```
Creates a graph object with n vertices with the edges specified in the edge list given by the range [first, last). The value type of the EdgeIterator must be a std::pair, where the type in the pair is an integer type. The integers will correspond to vertices, and they must all fall in the range of [0, n).
(Required by IteratorConstructibleGraph.)
```template <typename EdgeIterator, typename EdgePropertyIterator>
EdgePropertyIterator ep_iter,
vertices_size_type n,
const GraphProperty& p = GraphProperty())
```
Creates a graph object with n vertices, with the edges specified in the edge list given by the range [first, last). The value type of the EdgeIterator must be a std::pair, where the type in the pair is an integer type. The integers will correspond to vertices, and they must all fall in the range of [0, n). The value_type of the ep_iter should be EdgeProperty.

Non-Member Functions

```std::pair<vertex_iterator, vertex_iterator>
```
Returns an iterator-range providing access to the vertex set of graph g.
(Required by VertexListGraph.)
```std::pair<edge_iterator, edge_iterator>
```
Returns an iterator-range providing access to the edge set of graph g.
(Required by EdgeListGraph.)
```std::pair<adjacency_iterator, adjacency_iterator>
```
```std::pair<out_edge_iterator, out_edge_iterator>
```
Returns an iterator-range providing access to the out-edges of vertex v in graph g. If the graph is undirected, this iterator-range provides access to all edges incident on vertex v.
(Required by IncidenceGraph.)
```vertex_descriptor
```
Returns the source vertex of edge e.
(Required by IncidenceGraph.)
```vertex_descriptor
```
Returns the target vertex of edge e.
(Required by IncidenceGraph.)
```degree_size_type
```
Returns the number of edges leaving vertex u.
(Required by IncidenceGraph.)

```std::pair<in_edge_iterator, in_edge_iterator>
```
Returns an iterator-range providing access to the in-edges of vertex v in graph g. If the graph is undirected, this iterator-range provides access to all edges incident on vertex v.
(Required by BidirectionalGraph.)
```degree_size_type
```
Returns the number of edges entering vertex u.
(Required by BidirectionalGraph.)

```vertices_size_type num_vertices(const adjacency_matrix& g)
```
Returns the number of vertices in the graph g.
(Required by VertexListGraph.)
```edges_size_type num_edges(const adjacency_matrix& g)
```
Returns the number of edges in the graph g.
(Required by EdgeListGraph.)
```vertex_descriptor vertex(vertices_size_type n, const adjacency_matrix& g)
```
Returns the nth vertex in the graph's vertex list.
```std::pair<edge_descriptor, bool>
edge(vertex_descriptor u, vertex_descriptor v,
```
Returns the edge connecting vertex u to vertex v in graph g.
```std::pair<edge_descriptor, bool>
```
Adds edge (u,v) to the graph and returns the edge descriptor for the new edge. If the edge is already in the graph then a duplicate will not be added and the bool flag will be false. This operation does not invalidate any of the graph's iterators or descriptors.
(Required by MutableGraph.)
```std::pair<edge_descriptor, bool>
const EdgeProperty& p,
```
Adds edge (u,v) to the graph and attaches p as the value of the edge's internal property storage. Also see the previous add_edge() member function for more details.
```void remove_edge(vertex_descriptor u, vertex_descriptor v,
```
Removes the edge (u,v) from the graph.
(Required by MutableGraph.)
```void remove_edge(edge_descriptor e, adjacency_matrix& g)
```
Removes the edge e from the graph. This is equivalent to calling remove_edge(source(e, g), target(e, g), g).
(Required by MutableGraph.)
```void clear_vertex(vertex_descriptor u, adjacency_matrix& g)
```
Removes all edges to and from vertex u. The vertex still appears in the vertex set of the graph.
(Required by MutableGraph.)
```template <typename Property>

template <typename Property>
```
Returns the property map object for the vertex property specified by Property. The Property must match one of the properties specified in the graph's VertexProperty template argument.
(Required by PropertyGraph.)
```template <typename Property, typename X>
typename property_traits<
>::value_type
get(Property, const adjacency_matrix& g, X x)
```
This returns the property value for x, which is either a vertex or edge descriptor.
(Required by PropertyGraph.)
```template <typename Property, typename X, typename Value>
void
put(Property, const adjacency_matrix& g, X x, const Value& value)
```
This sets the property value for x to value. x is either a vertex or edge descriptor. Value must be convertible to typename property_traits<property_map<adjacency_matrix, Property>::type>::value_type.
(Required by PropertyGraph.)
```template <typename GraphProperty, typename GraphProperty>
typename property_value<GraphProperty, GraphProperty>::type&
```template <typename GraphProperty, typename GraphProperty>