Notes
Notes - notes.io |
#include<stdlib.h>
#include<math.h>
#define max 20
int g[max][max],n,visited[10],visited1[10];
void creation()
{
int i,j;
printf ("Enter the number of citiesn");
scanf ("%d",&n);
printf ("Enter the edgesn");
for (i=0;i<n;i++)
{
for (j=0;j<n;j++)
{
scanf ("%d",&g[i][j]);
}
}
printf ("It has been createdn");
}
void reachable(int source)
{
int q[10],f,r;
int u,v;
int i;
f=0;r=-1;
q[++r]=source;
visited[source]=1;
while (f<=r)
{
u=q[f++];
for (v=0;v<n;v++)
{
if (visited[v]==0 && g[u][v]==1)
{
visited[v]=1;
r++;
q[r]=v;
}
}
}
for (i=0;i<n;i++)
{
if (visited[i]==1)
printf ("%d reachablen",i);
else
printf ("%d not reachablen",i);
}
}
void connection(int source)
{
connectivity(source);
int i=0;
int flag=1;
for (i=0;i<n;i++)
{
if (visited1[i]==0)
{
flag=0;
}
}
if (flag==0)
printf ("no connectivityn");
else
printf ("yesss cn");
}
void connectivity(int source)
{
int v;
visited1[source]=1;
for (v=0;v<n;v++)
{
if (visited1[v]==0 && g[source][v]==1)
connectivity(v);
}
}
void main()
{
int choice, source;
while (1)
{
printf ("1.Creation 2.Reachability 3.Connectivity 4.Exitn");
scanf ("%d",&choice);
switch (choice)
{
case 1:creation();break;
case 2: printf ("Enter the sourcen");
scanf ("%d",&source);
reachable(source);break;
case 3: printf ("Enter the sourcen");
scanf ("%d",&source);
connection(source);break;
case 4:exit (0);
default: printf ("Invalidn");
}
}
}
|
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team