%% Remove Self-Loops
% This example shows how to remove all of the self-loops from a graph. Self-loops are edges that connect a node to itself.
% Create a graph that has two self-loops.

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

%
% Use rmedge to remove all self-loops from the graph. Even though G has only two self-loops, this technique removes all self-loops from any directed or undirected graph.

G = rmedge(G, 1:numnodes(G), 1:numnodes(G));
plot(G)

% Copyright 2012 The MathWorks, Inc.