function [V,E,C,bdry_cells]=vertex_edges_cells(center_positions,DPLAY) %[V,E,C,bdry_cells]=vertex_edges_cells(center_positions); %P - Output of function centers_list.m %V - Two column list of positions of vertices comprising cellular network %E - Two column list of vertices that form the interior edges of the %cellular network. %C - Cell array, indicating vertrices bounding individual cells, listed to %correspond to the Numeric label in 'P' %bdry_cells - Labels of cells in 'C' (and 'P'), that have vertices at the %boundaries. Edges of these cells are not reliable physical %representations. % %Display results if DPLAY='ON'; % %For bugs, comments, etc. please contact Kapil Krishan : %kkrishan@uci.edu %www.physics.uci.edu/~foams %version: I %Using the x,y coordinates of each cell center to extract the Voronoi %diagram vertices, and cell centers x=center_positions(:,1);y=center_positions(:,2); [V,C] = voronoin([x y]); %'bdry_cells' indicates the cells whose vertices lie outside the boundary bdry_vtxs=unique([find(V(:,1)>max(x));find(V(:,1)max(y));find(V(:,2)0 bdry_cells=[bdry_cells;cell_no]; end end ct=0;%counter for ic=setdiff([1:size(C,1)],bdry_cells')%'ic' enumerates interior cells ct=ct+1; C_interior{ct}=C{ic}; end C_interior=C_interior';%'C_interior' is a cell array comprising only of interior cells E=[0 0];%dummy initialization, gotten rid off in 5 lines. for ic=1:size(C_interior,1) vtxs=C_interior{ic};%Vertices of the 'ic'th interior cell E=[E;setdiff(sort([vtxs;[vtxs(2:end) vtxs(1)]])',E,'rows')];%unique list of edges of cells thus far. end E(1,:)=[];%complete list of non-boundary edges. %DISPLAY RESULTS ONLY %All the following lines display the primary results of the program. They may %be commented out. if strcmp(DPLAY,'ON')==1 hold on; for ic=1:size(E,1) line([V(E(ic,1),1) V(E(ic,2),1)],[V(E(ic,1),2) V(E(ic,2),2)],'color',[0 0 0]); title('Voronoi construction') end;drawnow; end