www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/ReverseSubsetOfGraphEdgesExample.m

    %% Reverse Subset of Graph Edges
% Create and plot a directed graph. Specify custom _xy_ node coordinates
% for the plot.
G = digraph([1 1 2 2 3],[2 3 3 4 5]);
x = [1 0 2 -1 3];
y = [1 2 2 2.5 2.5];
plot(G,'XData',x,'YData',y)

%%
% Reverse the direction of the edges (2,4) and (3,5), and then replot the
% graph.
H = flipedge(G,[2 3],[4 5]);
plot(H,'XData',x,'YData',y)