Dear faraz
thanks for your reply. i already did this. but it not works that perfectly. I m sending u an exapmle. my problem is that i have a graph with n nodes. if the distance between nodes is lesser then ther transmission rnage then it will be connected otherwise not.
clear all;
close all;
clc;
R=4;
a=0;
X=[1,1,2,3,3,4,5,5,5,6,7,7,7,9,9,9,11,11,11,12,13,13,13,14,15];
Y=[7,13,3,4,9,13,1,7,11,5,3,9,13,6,9,11,2,10,14,5,3,6,10,1,14];
plot(X,Y,'*');
hold on;
for i=1:25
x1=X(i);
y1=Y(i);
for j=1:25
if(i~=j)
grid on;
x2=X(j);
y2=Y(j);
d=sqrt((x1x2)^2+(y1y2)^2);
if d<=R
plot([X(i) X(j)],[Y(i) Y(j)],'');
G(i,j)=d;
a=a+1;
end;
hold on;
end
end
end
axis([0 16 0 16])
a
G
H=sparse(G)
[dist, path]= graphshortestpath(H, 2 , 14)
so how to sort it according to there weight.
"Faraz Afzal" <farazafzal@gmail.com> wrote in message <i0fg88$e5k$1@fred.mathworks.com>...
> "Aman " <am.amangupta@gmail.com> wrote in message <i0feif$mab$1@fred.mathworks.com>...
> > i had generte a graph G(V,E),where V is vertices and E is Edges. now i want to sort all the edges in acesding order of weight.
> >
> > G=
> > 1.0e+007 *
> >
> > (10,1) 1.2119
> > (11,1) 1.0673
> > (13,1) 0.0182
> > (22,1) 2.0078
> > (31,1) 3.0406
> > (53,1) 0.8702
> > (54,1) 1.3758
> > (55,1) 2.7643
> > (91,1) 0.0813
> > (96,1) 0.3636
> > (8,2) 1.3434
> > (9,2) 0.1211
> > (25,2) 0.7739
> > (40,2) 0.0078
> > (48,2) 1.8768
> > (75,2) 0.6803
> > (7,3) 0.2628
> > (28,3) 1.5333
> > (63,3) 1.5905
> > (76,3) 0.0208
> > (77,3) 1.8958
> > (80,3) 1.6999
> > (82,3) 0.2793
>
>
> Dear Gupta,
>
> Try always to explain your problem a little bit.
> If you can always come up with examples it would make us to reply you faster.
>
> Say your second column in MATRIX G is Edges that you would like to sort.
> G(:,2) = sort(G(:,2))
>
> Let me know if it works.
>
> Regards,
> Muhammad Faraz
