reordernodes
Renumbers the nodes of a graph.
Category: Mathematics > Graph and Network Algorithms
Syntax
H = reordernodes(G, order)
Places node order(k) of G at position k in H.
Description
The structure of the graph does not change, only the numbering, so H is isomorphic to G. A new numbering matters when it makes the adjacency matrix more structured, for example after sorting by degree or by a component label, or to put the nodes in topological order.
Input arguments
G- A
graphordigraph. order- Permutation of
1:numnodes(G), or a cell array of node names in the new order.
Output arguments
H- The same graph with permuted node numbers. Edges, weights and node properties travel with their nodes.
Example
Rotate the numbering
G = graph([1 2], [2 3]);
H = reordernodes(G, [3 1 2]);
disp(H.Edges.EndNodes)
isisomorphic(G, H)
Output
1 3
2 3
ans = logical
1