Assign labels to vertices of g
With no arguments, we assign default names for vertices (string versions
of the vertex numbers)
label(g,v,name) gives vertex v the name in the string name.
label(g,vnamelist) assigns names to vertices in the cell array vlist
CROSS-REFERENCE INFORMATION
This function calls:
clear_labels clearl_labels(g) --- delete all labels in g
is_labeled is_labeled(g) --- determine if there are labels on vertices.
0001 function label(g,v,name)
0002 % Assign labels to vertices of g
0003 % With no arguments, we assign default names for vertices (string versions
0004 % of the vertex numbers)
0005 % label(g,v,name) gives vertex v the name in the string name.
0006 % label(g,vnamelist) assigns names to vertices in the cell array vlist
0007
0008
0009 global GRAPH_MAGIC;
0010
0011 n = nv(g);
0012 i = g.idx;
0013
0014 if nargin == 1
0015 clear_labels(g);
0016 GRAPH_MAGIC.graphs{i}.labels = cell(n,1);
0017 for v=1:n
0018 GRAPH_MAGIC.graphs{i}.labels{v} = int2str(v);
0019 end
0020 return
0021 end
0022
0023 if nargin == 2
0024 clear_labels(g);
0025 GRAPH_MAGIC.graphs{i}.labels = v;
0026 return
0027 end
0028
0029 if ~is_labeled(g)
0030 label(g);
0031 end
0032
0033 if (v<0) || (v>n)
0034 error('No such vertex to label')
0035 end
0036
0037 GRAPH_MAGIC.graphs{i}.labels{v} = name;