%% Add Edges with Attributes to Graph
% Create a graph whose edges have the attributes Weight and Power. Use an edge table to create the graph.

EdgeTable = table([1 2; 2 3; 2 4; 2 5; 5 6; 5 7; 5 8], ...
    {'on','off','off','on','on','on','off'}',[10 20 20 10 10 10 20]', ...
    'VariableNames',{'EndNodes','Power','Weight'});
G = graph(EdgeTable)

%
% Add two new edges to the graph by creating a smaller table that can be concatenated to G.Edges. Note that this smaller table must use the same order of variables as G.Edges.

NewEdges = table([5 9; 3 6], {'on' 'off'}', [10 20]', ...
    'VariableNames',{'EndNodes','Power','Weight'});
G = addedge(G,NewEdges)

%
% View the new edge list of the graph, which includes the added edges.

G.Edges

% Copyright 2015 The MathWorks, Inc.