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

    %% Add Text Labels to Graph Edges
% Create and plot a graph.

% Copyright 2015 The MathWorks, Inc.

s = [1 1 2 2 3];
t = [2 3 3 4 4];
G = graph(s,t);
h = plot(G);

%%
% Add text labels to three of the five graph edges.
labelText = {'ABC' 'DEF' 'GHI'};
labeledge(h,[1 1 2],[2 3 3],labelText)