%% Add Nodes and Edges to Empty Graph
% Create an empty graph object, G.

G = graph;

%
% Add three nodes and three edges to the graph. The corresponding entries in s and t define the end nodes of the graph edges. addedge automatically adds the appropriate nodes to the graph if they are not already present.

s = [1 2 1];
t = [2 3 3];
G = addedge(G,s,t)

%
% View the edge list. Each row describes an edge in the graph.

G.Edges

% For the best performance, construct graphs all at once using a single call to graph. Adding nodes or edges in a loop can be slow for large graphs.
% Copyright 2015 The MathWorks, Inc.