H = flipedge(G)
returns a directed graph that has the same edges as G, but with
reversed directions. H contains the same node and edge properties
as G.
Input graph, specified as a digraph object. Use digraph to create a directed graph object.
Example: G = digraph([1 2],[2 3])
s,t — Node pairs (as separate arguments) node indices | node names
Node pairs, specified as separate arguments of node indices or node names.
Similarly located elements in s and t
specify the source and target nodes for edges in the graph.
This table shows the different ways to refer to one or more nodes either by their numeric node indices or by their node names.
Form
Single Node
Multiple Nodes
Node index
Scalar
Example:1
Vector
Example:[1 2 3]
Node name
Character vector
Example:'A'
Cell array of character vectors
Example:{'A' 'B' 'C'}
String scalar
Example:"A"
String array
Example:["A" "B" "C"]
Example: H = flipedge(G,[1 4],[2 3]) reverses the
direction of the edges (1,2) and (4,3).
Example: H = flipedge(G,{'a' 'd'},{'b' 'c'}) reverses
the direction of the edges (a,b) and (d,c).
idx — Edge indices scalar | vector
Edge indices, specified as a scalar or vector of positive integers. Each
edge index corresponds to a row in the G.Edges table of
the graph G.Edges(idx,:).
Example: H = flipedge(G,3) flips the direction of edge
G.Edges(3,:).
Output graph, returned as a digraph object. Compared to
G, H has the same nodes but some
or all of the edges are in reversed direction. H also has
the same node and edge properties as G.
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.