项目主页:http://www.ogdf.net/
开源 (GNU/GPL),有不错的示例、文档(都是英文的←_←)
- 配置方法可参考官方提供的说明
- Installation (Windows / Visual Studio): http://www.ogdf.net/doku.php/tech:installvcc
- 以下描述以 Visual Studio 2012 为例。
主要步骤:下载源码, 编译安装, 配置工程, have fun!
Step1>>下载源码
- http://www.ogdf.net/doku.php/tech:download
- Current Release: v. 2015.05 (Baobab) [5.4 MB]
Step2>>编译安装
- 执行 makeVCXProj.py 脚本:生成 VS 工程 ogdf.vcxproj, coin.vcxproj 和解决方案 ogdf.sln。不需要 cmake,但是……好像需要个 python 解释器
- 用 VS 打开 ogdf.sln,“生成解决方案”。
- 你会得到一些 lib、obj 文件。我的在 OGDF\Win32\Debug 目录下
Step3>>配置工程
- 添加包含目录、库目录
- 在解决方案管理器中右击你的工程,属性。配置属性>VC++目录:
- 在“包含目录”中添加 OGDF\include
- 在“库目录”中添加 ogdf.lib、coin.lib这两个文件所在的目录(上一小步中的 OGDF\Win32\Debug)
- 也可以将以上路径添加到相应环境变量中
- 为链接器附加库 ogdf.lib、coin.lib
- 还在工程属性对话框中,配置属性 > 链接器 > 输入,在“附加依赖项”中添加“ogdf.lib;coin.lib;”。
- 也可写在源代码文件里,
#pragma comment(lib,"C:/blablabla/ogdf.lib") #pragma comment(lib,"C:/blablabla/coin.lib")
Step4>>hello world
#include
using namespace ogdf;
int main(){
Graph G;
node a = G.newNode();
node b = G.newNode();
node c = G.newNode();
G.newEdge(a, b);
G.newEdge(b, c);
GraphAttributes GA(G);
FMMMLayout fmmm;
fmmm.call(GA);
cout << GA.x(a) << ", " << GA.y(a) << "; \n";
cout << GA.x(b) << ", " << GA.y(b) << "; \n";
cout << GA.x(c) << ", " << GA.y(c) << "; \n";
return 0;
}
//代码很丑陋,这只是个hello world,莫吐槽
一次运行的结果:
25, 25; 59, 60; 93, 93; 请按任意键继续. . .
(完)
支持下