源码下载及编译
目前最新版本iGraph0.8.0,下载路径如下:
https://download.csdn.net/download/XIANG__jiangsu/12179284
- 下载好后解压,运行igraph工程,重新编译,编译完成后在Debug下生成igraph.lib;
- 新建一个空的C++项目
- 配置环境,依次是:附加包含目录(include所在路径)、附加库目录(igraph.lib所在路径)、附加依赖项igraph.lib
- 忽略特定默认库,之所以要忽略,是因为静态lib库中已包含这些函数实现,因此要忽略。
- 添加预处理器定义,该定义会让lib以c的形式去编译代码,否则在代码编译时默认采用c++方式,会给每个函数加前缀名,导致链接失败。
- 添加代码测试
// CPlusTest.cpp : 定义控制台应用程序的入口点。
#include "stdafx.h"
#include <stdio.h>
#include "igraph.h"
int _tmain(int argc, _TCHAR* argv[])
{
igraph_t g;
FILE *outfile;
igraph_barabasi_game(&g, 1000, /*power=*/ 1,/*m=*/2, /*outseq=*/0,
/*outpref=*/0, /*A=*/ 1, /*directed=*/1,
IGRAPH_BARABASI_PSUMTREE,
/*start_from=*/ 0);
igraph_simplify(&g, /*multiple=*/1, /*loops=*/0, /*edge_comb=*/ 0);
outfile=fopen("gxout.txt", "w");
igraph_write_graph_edgelist(&g, outfile);
fclose(outfile);
igraph_destroy(&g);
return 0;
}
最终生成一个结果文件。