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

    %% Locate Edges with Specified End Nodes
% Create a graph, and then determine the edge index for the (1,2) and (3,5)
% edges.

% Copyright 2015 The MathWorks, Inc.

s = [1 1 2 2 2 3 3 3];
t = [2 3 3 4 5 6 7 5];
G = graph(s,t)

%%
%
idxOut = findedge(G,[1 3],[2 5])

%%
% |idxOut| contains the row index into |G.Edges.EndNodes| for each
% specified edge.