# Documentation

### This is machine translation

Translated by
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

# `Graph`::`revert`

Reverts the edges of a graph.

MuPAD® notebooks are not recommended. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.

## Syntax

```Graph::revert(`G`)
```

## Description

`Graph::revert(G)` returns a graph in which all edges [u, v] and their properties belong to edges [v, u].

`Graph::revert` overloads the system function `revert`.

## Examples

### Example 1

First, a circle graph is defined with some additional settings:

```G1 := Graph::createCircleGraph(3): G1 := Graph::setEdgeWeights(G1, [[1, 2]], [20]): G1 := Graph::setEdgeCosts(G1, [[1, 2]], [20]): G1 := Graph::setEdgeDescriptions(G1, [[1, 2]], ["Shortcut"]): Graph::printGraphInformation(G1)```
```Vertices: [1, 2, 3] Edges: [[1, 2], [2, 3], [3, 1]] Vertex weights: no vertex weights. Edge descriptions: [1, 2] = "Shortcut" Edge weights: [1, 2] = 20 (other existing edges have no weight) Edge costs: [1, 2] = 20 (other existing edges have costs zero) Adjacency list (out): 1 = [2], 2 = [3], 3 = [1] Adjacency list (in): 1 = [3], 2 = [1], 3 = [2] Graph is directed. ```

Now we revert the graph:

```G2 := revert(G1): Graph::printGraphInformation(G2)```
```Vertices: [1, 2, 3] Edges: [[1, 3], [2, 1], [3, 2]] Vertex weights: no vertex weights. Edge descriptions: [2, 1] = "Shortcut" Edge weights: [2, 1] = 20 (other existing edges have no weight) Edge costs: [2, 1] = 20 (other existing edges have costs zero) Adjacency list (out): 1 = [3], 2 = [1], 3 = [2] Adjacency list (in): 1 = [2], 2 = [3], 3 = [1] Graph is directed. ```

## Parameters

 `G` A graph

## Return Values

Graph

Was this topic helpful?

Watch now