idx = find_available Find the first available slot in the GRAPH_MAGIC machinery or 0 if no slot is available. NOTE: This is used by the @graph constructor. No reason the user should call this directly.
0001 function idx = find_available 0002 % idx = find_available 0003 % Find the first available slot in the GRAPH_MAGIC machinery or 0 if no 0004 % slot is available. 0005 % NOTE: This is used by the @graph constructor. No reason the user should 0006 % call this directly. 0007 0008 0009 0010 global GRAPH_MAGIC 0011 0012 0013 % see if all the slots are taken 0014 if (sum(GRAPH_MAGIC.in_use) == GRAPH_MAGIC.ngraphs) 0015 idx = 0; 0016 return 0017 end 0018 0019 % If we made it this far, there's an available slot. Now we just find one. 0020 idx = find(GRAPH_MAGIC.in_use == 0); 0021 idx = idx(1);