#include<stdio.h>
struct node
{
int vertex;
struct node * next;
}*v[10];
void createmat(int m[10][10],int n)
{
int i,j;
char ans;
for(i=0;i<n;i++)
for(j=0;j<n;j++)
{
m[i][j]=0;
if(i!=j)
{
printf("is there any edge between vertex %d and %d(1,0):",i+1,j+1);
scanf("%d",&m[i][j]);
}
}
}
void isempty(int m[10][10],int n)
{
int i,j;
printf("\nthe adjacency matrix is:\n");
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
printf("\t%d",m[i][j]);
printf("\n");
}
}
void createlist(int m[10][10],int n)
{
int i,j;
struct node *temp,*newnode;
for(i=0;i<n;i++)
{
v[i]=NULL;
for(j=0;j<n;j++)
{
if(m[i][j]==1)
{
newnode=(struct node*)malloc(sizeof(struct node));
newnode->next=NULL;
newnode->vertex=j+1;
if(v[i]==NULL)
v[i]=temp=newnode;
else
{
temp->next=newnode;
temp=newnode;
}
}
}
}
}
void displist(int n)
{
struct node *temp;
int i;
printf("\n adjacency list is \n");
for(i=0;i<n;i++)
{
printf("\n v%d->",i+1);
temp=v[i];
while(temp)
{
printf("v%d->",temp->vertex);
temp=temp->next;
}
printf("NULL");
}
}
void main()
{
int m[10][10],n;
clrscr();
printf("\n enter the no of vertex:");
scanf("%d",&n);
createmat(m,n);
isempty(m,n);
createlist(m,n);
displist(n);
getch();
}
struct node
{
int vertex;
struct node * next;
}*v[10];
void createmat(int m[10][10],int n)
{
int i,j;
char ans;
for(i=0;i<n;i++)
for(j=0;j<n;j++)
{
m[i][j]=0;
if(i!=j)
{
printf("is there any edge between vertex %d and %d(1,0):",i+1,j+1);
scanf("%d",&m[i][j]);
}
}
}
void isempty(int m[10][10],int n)
{
int i,j;
printf("\nthe adjacency matrix is:\n");
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
printf("\t%d",m[i][j]);
printf("\n");
}
}
void createlist(int m[10][10],int n)
{
int i,j;
struct node *temp,*newnode;
for(i=0;i<n;i++)
{
v[i]=NULL;
for(j=0;j<n;j++)
{
if(m[i][j]==1)
{
newnode=(struct node*)malloc(sizeof(struct node));
newnode->next=NULL;
newnode->vertex=j+1;
if(v[i]==NULL)
v[i]=temp=newnode;
else
{
temp->next=newnode;
temp=newnode;
}
}
}
}
}
void displist(int n)
{
struct node *temp;
int i;
printf("\n adjacency list is \n");
for(i=0;i<n;i++)
{
printf("\n v%d->",i+1);
temp=v[i];
while(temp)
{
printf("v%d->",temp->vertex);
temp=temp->next;
}
printf("NULL");
}
}
void main()
{
int m[10][10],n;
clrscr();
printf("\n enter the no of vertex:");
scanf("%d",&n);
createmat(m,n);
isempty(m,n);
createlist(m,n);
displist(n);
getch();
}
Online Gaming in USA: NJ casinos offering legal - JTM Hub
ReplyDeleteNJ online 서울특별 출장마사지 casinos are 당진 출장마사지 legal and licensed 정읍 출장마사지 in the state of New 익산 출장안마 Jersey, with many gaming options on offer and some casinos accepting 전주 출장안마 players from