and PG level projects,mini projects and many more here ...

Program fragments

Small fragments of the program are presented as below. Nodes are createdby generating unique ID for each node. As nodes are randomly scattered over an area, their position is located by randomly generating x and y coordinates as shown in the program.


Node structure

%Node structure

%create global node;


% initially all nodes are unclustered for i=1:no_of_nodes



% now randomly generate coordinates for nodes

% now we will populate the array

% with random numbers for coordinates

for i=1:no_of_nodes

x_coord_val=round(area_side*rand); % generated random x coordinate for the node node(i).x_coord=x_coord_val;

y_coord_val=round(area_side*rand); % generated random number for y coordinate node(i).y_coord=y_coord_val;

% also assign an ID for that node node(i).ID=i;


Structure of cluster

Similar to nodes unique ID is also generated for each cluster. The program fragment show how cluster created.

%============== Now we will define the cluster structures ==========

global cluster_id_global;



% generate n number of clusters with unique IDs i.e. total n number of unique

cluster IDs will be generated

% ----following lines are required by the unique no () function global uniq_array;


global p; global q; p=1; q=1;

% --------populate cluster ID global array --- 2000 clusters supported, so min 2000

nodes will be supported---------------- for i=1:no_of_nodes

temp=unique_no(3); % any argument passed--needed for compilation temp2=num2str(temp);

pp=strcat('clusterID',temp2); % generate unique cluster IDs %disp(pp); cluster_id_global(i).clusterID=pp; % populated the global cluster ID filed end;