# `transpose_graph`

Graphs: | directed (and not undirected)
Properties: | vertex index
Complexity: | O(V + E)

    (1)
    template <class VertexListGraph, class MutableGraph>
    void transpose_graph(const VertexListGraph& G, MutableGraph& G_T);

    (2)
    template <class VertexListGraph, class MutableGraph, class VertexIndexMap>
    void transpose_graph(const VertexListGraph& G, MutableGraph& G_T,
                         VertexIndexMap index);

This function computes the transpose of a directed graph. The transpose of a directed graph G = (V, E)is the graph GT = (V, ET) , where ET = {(v, u) in V x V: (u, v) in E} . i.e., GT is G with all its edges reversed. Graph `G_T` passed into the algorithm must have the same number of vertices as `G` and no edges. The edges will be added by `transpose_graph()` by calling `add_edge` as follows for each edge (u,v) in `G`:

    add_edge(vertex(get(index, v), G_T), vertex(get(index, u), G_T), G_T);

### Where Defined

`boost/graph/transpose_graph.hpp`

### Requirements on Types

- The graph type for argument `G` must be a model of VertexListGraph.
- In version (1), the graph `G` must be a PropertyGraph with respect to the `vertex_index_t` property.
- The graph type for argument `G_T` must be a model of MutableGraph.
- The `VertexIndexMap` is a ReadablePropertyMap that must map the vertex descriptors of `G` to the integers from 0 to `num_vertices(G)`.

### Complexity

The time complexity is O(V + E).

Copyright © 2000 | Jeremy Siek, Univ.of Notre Dame (jsiek@lsc.nd.edu)