~dgleich/matlab-bgl/master

« back to all changes in this revision

Viewing changes to circle_graph_layout.m

  • Committer: David Gleich
  • Date: 2008-09-29 22:06:39 UTC
  • mfrom: (1.1.19 work)
  • Revision ID: dgleich@stanford.edu-20080929220639-4ic8mxd20lu81dla
Incorporated misc. fixes and graph layout algorithms.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
function X = circle_layout(G,radius)
 
2
% CIRCLE_LAYOUT Layout the vertices of a graph on a circle
 
3
 
4
% X = circle_layout(G) generates a layout of graph with vertices uniformly
 
5
% placed on the circle.  This function does no interesting layout and just
 
6
% places the vertices around the circle in order.
 
7
%
 
8
% X = circle_layout(G,radius) places the vertices with a radius other than
 
9
% 1.0.
 
10
%
 
11
% Example:
 
12
%   G = cycle_graph(6);
 
13
%   X = circle_layout(G);
 
14
%   gplot(G,X);
 
15
 
 
16
% David F. Gleich
 
17
% Copyright, Stanford University, 2008
 
18
 
 
19
%% History
 
20
%  2008-09-25: Initial coding
 
21
%%
 
22
 
 
23
if ~exist('radius','var') || isempty(radius), radius = 1.0; end;
 
24
pi = 3.14159;
 
25
n = num_vertices(G);
 
26
X = zeros(n,2);
 
27
X(:,1) = radius*cos( (0:n-1)'*2*pi/n );
 
28
X(:,2) = radius*sin( (0:n-1)'*2*pi/n );