Code covered by the BSD License  

Highlights from
Matgraph

from Matgraph by Ed Scheinerman
Toolbox for working with simple, undirected graphs

Description of label
Home > matgraph > @graph > label.m

label

PURPOSE ^

Assign labels to vertices of g

SYNOPSIS ^

function label(g,v,name)

DESCRIPTION ^

 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.
  • label Assign labels to vertices of g
  • nv nv(g) --- number of vertices in g
This function is called by:
  • cartesian cartesian(g,h1,h2) --- overwrite g with the product of h1 and h2
  • cayley cayley(g,perms) -- create a Cayley graph (undirected)
  • copy_labels copy_labels(g,h) --- copy labels from h to g
  • dot dot(g,filename) --- save graph for use by graphviz.
  • draw_labels draw_labels(g) --- add labels to a drawing of g
  • induce induce --- create induced subgraphs
  • label Assign labels to vertices of g
  • load load(g,filename) --- read a saved graph on disk
  • shiftgraph shiftgraph(g,k,t) -- create a shiftgraph g based on t-tuples of k symbols
  • sl2graph sl2graph(g,p) -- create an SL(2,p) graph

SOURCE CODE ^

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;

Generated on Thu 13-Mar-2008 14:23:52 by m2html © 2003

Contact us at files@mathworks.com