H = reordernodes(G,order)
reorders the nodes in graph G according to
order. This reordering corresponds to a symmetric permutation
of the adjacency matrix of G.
[H,idx]
= reordernodes(G,order)
also returns the permutation vector for the edge indices, idx.
For example, if G.Edges has a variable Weight,
then H.Edges.Weight == G.Edges.Weight(idx).
Input graph, specified as either a graph or digraph
object. Use graph to create an undirected graph or
digraph to create a directed graph.
Example: G = graph(1,2)
Example: G = digraph([1 2],[2 3])
Node order, specified as node indices or node names.
order specifies a symmetric permutation of the
adjacency matrix of G. If A =
adjacency(G), then A(order,order) produces
adjacency(H).
order can be one of:
Numeric vector of node indices, such as [1 3
2].
A cell array of character vectors or string array of node
names, such as {'A' 'C' 'B'} or ["A"
"C" "B"].
Output graph, returned as a graph or
digraph object. H contains the
same Nodes and Edges properties as
G, but with the rows of H.Nodes
and H.Edges permuted:
H.Nodes is the same as
G.Nodes(order,:).
H.Edges is similar to
G.Edges(idx,:), except that the nodes are
renumbered.
Permutation vector of edge indices, returned as a vector. The values in
idx describe the permutation of the rows in
G.Edges.
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window.
Web browsers do not support MATLAB commands.
Website auswählen
Wählen Sie eine Website aus, um übersetzte Inhalte (sofern verfügbar) sowie lokale Veranstaltungen und Angebote anzuzeigen. Auf der Grundlage Ihres Standorts empfehlen wir Ihnen die folgende Auswahl: .
Sie können auch eine Website aus der folgenden Liste auswählen:
So erhalten Sie die bestmögliche Leistung auf der Website
Wählen Sie für die bestmögliche Website-Leistung die Website für China (auf Chinesisch oder Englisch). Andere landesspezifische Websites von MathWorks sind für Besuche von Ihrem Standort aus nicht optimiert.