Input graph, specified as adigraphobject. Usedigraphto 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 insandtspecify 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 theG.Edgestable of the graphG.Edges(idx,:).
Example:H = flipedge(G,3)flips the direction of edgeG.Edges(3,:).
Output graph, returned as adigraphobject. Compared toG,Hhas the same nodes but some or all of the edges are in reversed direction.Halso has the same node and edge properties asG.
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.