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;

}

}
return x;
}

return(true);
}
}

node* insert ( node* x , int value){
node newnode;
newnode.data = value;
return x;
}

return NULL;
if(x->data == value){
delete x;
x = prev;
}
}
}

int main(){

ifstream fin("data1.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

## All 3 Replies

Do you know what this data means ?

``````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``````

Read it like this way :

``````1 2 3 4 5
----------
1 |0 1 1 0 1
2 |1 0 1 1 1
3 |1 1 0 0 0
4 |0 1 0 0 1
5 |1 1 0 1 0
----------``````

So for example, Node1 is connected to Node2, Node3, and Node5.

So that should give you an idea.

ha yeah i ment to put that in with my matrix but i know how they are connected, i made the graph and the matrix

So do you know how to read in from a file? google getline()

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.