#include<stdio.h>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <igraph.h>
using namespace std;
int main()
{
vector<int> X;//store X coordinate
vector<int> Y;//store Y coordinate
char *filepath="E:\\ltt\\dataset\\betweeness.csv";
igraph_t g;
FILE *input;
igraph_integer_t N,Ne,Maxdegree;
input=fopen(filepath,"r");
igraph_read_graph_edgelist(&g, input, 0, 0);
fclose(input);
N=igraph_vcount(&g);//number of vertex
Ne=igraph_ecount(&g);//number of edge
igraph_matrix_t res_1;
igraph_matrix_init(&res_1,N,2);
///Set the parameters as the discription
igraph_integer_t niter=500;
igraph_real_t maxdelta=N;
igraph_real_t area=N*N;
igraph_real_t coolexp=1.5;
igraph_real_t repulserad=N*N*N;
igraph_bool_t use_seed=false;
igraph_vector_t weight;
igraph_vector_t minx;
igraph_vector_t maxx;
igraph_vector_t miny;
igraph_vector_t maxy;
igraph_vector_init(&weight,Ne);
igraph_vector_init(&minx,N);
igraph_vector_init(&maxx,N);
igraph_vector_init(&miny,N);
igraph_vector_init(&maxy,N);
igraph_vector_init(&maxy,N);
igraph_vector_init(&maxy,N);
//igraph_layout_random(&g,&res_1);
igraph_layout_fruchterman_reingold(&g,&res_1,niter,maxdelta,area,coolexp,repulserad,use_seed,&weight,&minx,&maxx,&miny,&maxy);
int s=igraph_matrix_nrow(&res_1);
for(int i=0;i<s;i++)
{
X.push_back(MATRIX(res_1,i,0));
Y.push_back(MATRIX(res_1,i,1));
}
for(int i=0;i<X.size();i++)
{
cout<<"x"<<i<<"="<<X[i]<<","<<"y"<<i<<"="<<Y[i]<<endl;
}
igraph_matrix_destroy(&res_1);
}
No matter whether I used the "igraph_layout_random()" or the "igraph_layout_fruchterman_reingold()",the results are both as mentioned above.It means that the X cooridnate and the Y coordinate in the matrix res_1 is zero,.So it can't layout the graph. I don't know why and what's wrong with it .