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

    %% Incidence Matrix of Directed Graph
% Create a directed graph using an edge list, and then calculate the
% incidence matrix.

% Copyright 2015 The MathWorks, Inc.

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

%%
%
I = incidence(G)

%%
% Each column in |I| represents the source and target nodes of a single
% edge in |G|.