From: Aman on
i have a graph G with 25 nodes, 2 nodes are connected only if their transmission range is greater then the distance between nodes. I sort all the edges in order to there weights. Assume this graph is a K-connected(K=2). Now i want to remove some nodes and want to see that is still k-coonected or not. i m getting the proper logic for this. please help me. i m sending a example of graph.

%practical to check the process
close all;
clear all;
clc;
G = zeros(25,25);
a=0;
R=5;
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
x2=X(j);
y2=Y(j);
d=sqrt((x1-x2)^2+(y1-y2)^2);
if d<=R
plot([X(i) X(j)],[Y(i) Y(j)],'-');
grid on;
G(i,j)=d;
a=a+1;
end;
hold on;
end
end
a
axis([0 16 0 16])
G=sparse(G)
[n m ] = size(G);
cntr = 0;
for i=1:n
for j=1:m
if (G(i,j)>0)
cntr = cntr + 1;
A(cntr,1) = i;
A(cntr,2) = j;
B(cntr) = G(i,j);
end
end
end

[C I] = sort(B); %C is the sorted array of B and I is the index value of each element of B
for i=1:numel(C)%no of element in array C
sorted_E(i,1) = A(I(i),1);
sorted_E(i,2) = A(I(i),2);
sorted_E(i,3) = C(I(i));
end
%============================ till now its working properly.
cntr = 0;
G_k = zeros(n,m);%cerate a Matrix G_K of zeros%G_K is a k-connected graph
for i=1:numel(C)%no of element in array C
temp = iskconnected(G_k,k,sorted_E(i,1),sorted_E(i,2));
if (temp == 0)
cntr = cntr + 1;
G_k(sorted_E(i,1),sorted_E(i,2)) = sorted_E(i,3);
E_k(cntr,1) = sorted_E(i,1);
E_k(cntr,2) = sorted_E(i,2);
end
end

now i am trying to make a function "iskconnected" to check that after removing sum nodes between 2 connected nodes. Graph is still k-connected. for example node 1 and node 24 is connected and the path ([dist, path]=graphshortestpath(G, src , dest))
between them is [1 4 7 11 15 18 21 24], so i want to remove all the nodes(4 7 15 18 21 24) or (make it zero). and see that still 1 is coneected to 24 with anothe path. user have to input the source and destination node.