Documentation Center

  • Trial Software
  • Product Updates

Graph::revert

Reverts the edges of a graph.

Use only in the MuPAD Notebook Interface.

This functionality does not run in MATLAB.

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?