Ash's Blog

CN –>> Broadcasting

Posted on: March 19, 2011

#include<stdio.h>

#include<conio.h>

int main()

{

int adj[20][20],span[20][20],i,j,n,visited[20];

clrscr();

printf(“Enter no. of nodes\n”);

scanf(“%d”,&n);

printf(“Enter adjacency matrix for subnet\n”);

for(i=0;i<n;i++)

for(j=0;j<n;j++)

{

scanf(“%d”,&adj[i][j]);

span[i][j]=0;

visited[i]=0;

}

for(i=0;i<n;i++)

{

for(j=0;j<n;j++)

{

if(span[i][j]==0)

{

if(adj[i][j]==1 && i!=j && visited[j]!=1)

{

span[i][j]=1;

span[j][i]=1;

visited[i]=1;

visited[j]=1;

} } } }

printf(“Spanning tree\n”);

for(i=0;i<n;i++)

{

for(j=0;j<n;j++)

printf(“%d\t”,span[i][j]);

printf(“\n”);

}

getch();

return 0;

}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow up !

Enter your email address to follow this blog and receive notifications of new posts by email.

iTweet :

Where are you?

%d bloggers like this: