%% Preserve Self-Loops in Graph
% Simplify a graph while preserving self-loops using the 'keepselfloops' option.
%
% Create a multigraph with two nodes and several self-loops. Simplify the graph and preserve self-loops.

G = graph([1 1 1 1 1 1 1 2 2 2 2],[1 1 1 1 2 2 2 2 2 2 2 ]);
plot(G)
axis equal

%

G = simplify(G,'keepselfloops');
plot(G)
axis equal

% Copyright 2012 The MathWorks, Inc.