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

    %% Edge List Construction with Extra Nodes
% Create a weighted graph using a list of the end nodes of each edge.
% Specify that the graph should contain a total of 10 nodes.

% Copyright 2015 The MathWorks, Inc.

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

%%
% Plot the graph. The extra nodes are disconnected from the primary
% connected component.
plot(G)