please i need help in converting an array to a graph or converting an array to an adjacency list. basically the problem is about reading a table in excel into c++
table.txt(关联矩阵)
A B C D E
A 0 1 1 0 0
B 1 0 1 0 1
C 1 1 0 0 0
D 0 0 0 0 0
E 0 1 0 0 0
并将“矩阵”表示为图形,并进一步查找图形中的子图(聚类)。所以算法MCODE接收图并找到簇。如何将我已读取我的文件的数组转换为图形或邻接列表
这是我的代码
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
int array_size = 100048576;
char * array = new char[array_size];
int position = 0;
ifstream fin("c:\\disc.txt");
if(fin.is_open())
{
cout << "File Opened successfully!!!" << endl;
while(!fin.eof() && position < array_size)
{
fin.get(array[position]);
position++;
}
array[position-1] = '\0'; //placing character array terminating character
cout << "Displaying Array..." << endl << endl;
for(int i = 0; array[i] != '\0'; i++)
{
cout << array[i];
}
}
else //file could not be opened
{
cout << "File could not be opened." << endl;
}
return 0;
}