%% Graph Layout with Multiple Components
% Plot a graph that has multiple components, and then show how to use the 'UseGravity' option to improve the visualization.
%
% Create and plot a graph that has 150 nodes separated into many disconnected components. MATLAB® lays the graph components out on a grid.

s = [1 3 5 7 7 10:100];
t = [2 4 6 8 9 randi([10 100],1,91)];
G = graph(s,t,[],150);
h = plot(G);

%
% Update the layout coordinates of the graph object, and specify 'UseGravity' as true so that the components are layed out radially around the origin, with more space allotted for the larger components.

layout(h,'force','UseGravity',true)

% Copyright 2012 The MathWorks, Inc.