Hokay so, i gotta make a program that reads an adjacency matrix from a data file and then outputs which nodes are adjacent to the others. In the data file there are 0's and 1's, 0 means that they are not connected and a 1 means that they are. I got some of my code that allows me to remove and insert necessary nodes in the correct spot however im an stumped on my int main(){ and have no clue on what direction i should go or where i should start any comments would be much appreciated.
#include <iostream>
#include <fstream>
using namespace std;
typedef struct node{
int data;
node* link;
} node;
node* begin(node* linkHead){
return (node*)linkHead -> link;
}
node* end(node* linkHead){
node* x = linkHead;
while(x->link != NULL){
x = x->link;
}
return x;
}
bool empty(node* linkHead){
if(linkHead == NULL){
return(true);
}
}
node* insert ( node* x , int value){
node newnode;
newnode.data = value;
newnode.link = x -> link;
x -> link = &newnode;
return x;
}
node* remove (node* linkHead, int value){
if( linkHead = NULL)
return NULL;
node*x = linkHead;
node*prev = x->link;
x=x->link;
while(x->link != NULL){
if(x->data == value){
prev ->link = x->link;
delete x;
x = prev;
prev = x->link;
x = x->link;
}
}
}
int main(){
ifstream fin("data1.txt");
ofstream fout("adjacencylist.txt");
return 0;
}
(My data file)
0 1 1 0 1
1 0 1 1 1
1 1 0 0 0
0 1 0 0 1
1 1 0 1 0