Azzera filtri
Azzera filtri

How to find all possible path to destination?

1 visualizzazione (ultimi 30 giorni)
Asyran Abdullah
Asyran Abdullah il 25 Ago 2018
Risposto: Walter Roberson il 27 Ago 2018
Hi,
The clusterhead is already selected based on the distance value. However there is a problem to make connect a node to the clusterhead. I want to make a path from 4-9-1-3-5-CH, another route is 8-9-1-3-5-CH, 10-2-CH and 7-CH.
if true
%%%%%%%%%%%%%%%
clc;
clear all;
N=10; % No of nodes
data = rand(N,2); % Randomly generated n no. of nodes
x = data(:,1)*100;
y = data(:,2)*100;
numEdge = 19;
plot(x,y,'rx');
node=struct('id',{},'x',{},'y',{},'dist',{},'link',{'1'});
for i=1:N
node(i).id=i;
node(i).x=x(i);
node(i).y=y(i);
text(x(i),y(i),num2str(i));
end
%%%%%%%%%%%%%%%%%%
% CH
ch1=ceil(rand(1)*N);
text(node(ch1).x,node(ch1).y,['CH'],'Color' ,'b');
for i = 1:N
node(i).dist = sqrt(((node(ch1).x - node(i).x)^2 + (node(ch1).y - node(i).y)^2));
a(i)=node(i).dist;
disp(node(i).dist);
end
A=sort(a,'descend');
a=1;
for i = 1:N
node_distance(a) = node(i).dist;
a = a+1;
end
Maximum_distance = max(node_distance);
for i = 1:N
if node(i).dist == max(node_distance)
next_header = node(i).id;
end
end
end
The Result:
Accepted result:
How to make a connection between node to the clusterhead? Any function or clue for me?
Thanks.

Risposte (1)

Walter Roberson
Walter Roberson il 27 Ago 2018

Categorie

Scopri di più su Denoising and Compression in Help Center e File Exchange

Tag

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by