%% Determine Whether Undirected Graph Has Cycles
% Create and plot an undirected graph.

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

%
% Determine whether the graph has cycles.

tf = hascycles(G)

%
% Now add an edge to the graph between node 2 and node 3. Replot the graph.

G = addedge(G,2,3);
plot(G)

%
% Determine whether the new graph has cycles.

tf2 = hascycles(G)

%
% Copyright 2020 The MathWorks, Inc.