| Description of cdraw |
cdraw
PURPOSE 
cdraw(g,coloring) -- draw g with a given vertex coloring
SYNOPSIS 
function cdraw(g,coloring,line_style,color_matrix)
DESCRIPTION 
CROSS-REFERENCE INFORMATION 
This function calls:
- color color(g,algo) --- color the graph g by a given algorithm
- edge_color edge_color(g,algo) --- find a proper edge coloring of the graph g
- edges edges(g) --- list the edges in g as a 2-column matrix
- embed embed --- create an embedding for a graph
- getxy getxy(g) --- give g's embedding (or [] if g doesn't have one)
- hasxy hasxy(g) --- determine if an embedding has been created for g
- ne ne(g) --- number of edges in g or ne(g,h) --- check for inequality
- nv nv(g) --- number of vertices in g
- size size(g) --- returns [nv,ne] for the graph
This function is called by:
SOURCE CODE 
0001 function cdraw(g,coloring,line_style,color_matrix)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023 edge_color = 'k';
0024 vertex_color = 'k';
0025 r = 0.15;
0026
0027 if nargin < 3
0028 line_style = '-';
0029 end
0030
0031 if nargin < 2
0032 coloring = color(g,'greedy');
0033 end
0034
0035 n = nv(g);
0036 n2 = nv(coloring);
0037
0038 if nargin < 4
0039 color_matrix = hsv(np(coloring));
0040 end
0041
0042 if ~(n==n2)
0043 error('Graph and coloring must have equal number of vertices.')
0044 end
0045
0046 if ~hasxy(g)
0047 embed(g);
0048 end
0049
0050 xy = getxy(g);
0051
0052
0053 elist = edges(g);
0054 for j=1:ne(g)
0055 u = elist(j,1);
0056 v = elist(j,2);
0057 x = xy([u,v],1);
0058 y = xy([u,v],2);
0059 line(x,y,'Color', edge_color,'LineStyle',line_style);
0060 end
0061
0062
0063
0064 color_classes = parts(coloring);
0065 num_colors = np(coloring);
0066
0067 for i=1:num_colors
0068 color_class_size = size(color_classes{i},2);
0069 if ischar(color_matrix)
0070 vertex_fill = color_matrix(i) ;
0071 else
0072 vertex_fill = color_matrix(i,:);
0073 end
0074 for j=1:color_class_size
0075 v = color_classes{i}(j);
0076 x = xy(v,1);
0077 y = xy(v,2);
0078 rectangle('Position', [x-r/2, y-r/2, r, r],...
0079 'Curvature', [1 1], ...
0080 'EdgeColor', vertex_color, ...
0081 'FaceColor', vertex_fill);
0082 end
0083 end
0084
0085 axis equal
0086 axis off
Generated on Thu 13-Mar-2008 14:23:52 by m2html © 2003
|
|