0001 function graph_init(capacity)
0002
0003
0004
0005
0006
0007
0008 DEFAULT_CAPACITY = 500;
0009
0010
0011 if graph_system_exists
0012 disp('Graph system already initialized');
0013 disp('To start over, use graph_destroy');
0014 return;
0015 end
0016
0017 global GRAPH_MAGIC;
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030 if (nargin==0)
0031 capacity = DEFAULT_CAPACITY;
0032 end
0033
0034
0035 if (capacity < 1)
0036 capacity = DEFAULT_CAPACITY;
0037 end
0038
0039 GRAPH_MAGIC.ngraphs = capacity;
0040
0041 GRAPH_MAGIC.graphs = cell(capacity,1);
0042 GRAPH_MAGIC.in_use = zeros(capacity,1);
0043
0044 GRAPH_MAGIC.Q.array = [];
0045 GRAPH_MAGIC.Q.first = 0;
0046 GRAPH_MAGIC.Q.last = 0;
0047
0048
0049 disp(['Graph system initialized. Number of slots = ', ...
0050 int2str(capacity),'.']);
0051
0052 set_large(1000);