%% Edge Indices and Counts of Repeated Edges
% Use the second and third outputs of simplify to get information about how many (and which) edges are combined.
%
% Create an undirected multigraph with three nodes and four edges.

G = graph([1 1 1 2],[2 2 3 3]);
G.Edges

%
% Simplify the graph and specify three outputs to get additional information about the combined edges.

[G,ei,ec] = simplify(G)

%
% ei(i) is the edge in the simplified graph that represents edge i in the old graph. Since the first two edges are repeated, ei(1) = ei(2) = 1. Also, ec(1) = 2, since there are two edges in the new graph corresponding to edge 1 in the old graph.
% Copyright 2012 The MathWorks, Inc.