C++ OGDF Library in windows for beginner
需要工具
- CMake 3.1+
- C++11 compliant compiler
gcc 4.9.2+
clang 3.5+
Microsoft Visual C++ 2015+ - GNU Make (in most cases)
- Doxygen 1.8.6+ (optional)
- OGDF library
第一步:安装软件
下载cmake
cmake
下载gcc
gcc
note:记得添加 路径到系统变量
下载clang
clang
如果没安装clang可能cmake 配置的时候会出错
下载visual studio
visual studio 2019
GNU make 和 Doxygen 可以不安装
如果有要求就安装,我的作业就需要安装Doxygen,不然cmake过程就要报错
OGDF library
OGDF
第二步 配置
1.解压OGDF 在cmake 文件里新建一个空文件build
2,打开cmake 开始配置
note:
source code的位置就是ogdf的位置,里面有CMakeLists,不让报错
build binary 就是build 那个文件夹
configure 时候要选编译器,一般是第一个看自己装visual studio的版本
检查configure log 看是否有错,不让后面打开工程build solution会出问题
3.打开工程visual studio,打开build -->build solution,等十几分钟完成检查是否全部success
我遇到的问题 c2220
这样解决
4.新建项目–>build console app
右击project -->properties–>c++ -->additional include directories
添加两个include 一个在build文件里,一个在ogdf里
linker -->General -->additional library directories
添加release 文件,注意这里如果一开始build solution默认是debug 就要去找debug文件,lib文件在debug文件里
linker -->input -->additional dependencies
测试一下
#include<iostream>
#include<cmath>
#include<time.h>
#include <ogdf/energybased/FMMMLayout.h>
#include <ogdf/fileformats/GraphIO.h>
using namespace ogdf;
int main()
{
Graph G;
GraphAttributes GA(G);
if (!GraphIO::read(G, "C:/Protein_core_2.gml")) {
std::cerr << "Could not load sierpinski_04.gml" << std::endl;
return 1;
}
for (node v : G.nodes)
GA.width(v) = GA.height(v) = 10.0;
FMMMLayout fmmm;
fmmm.useHighLevelOptions(true);
fmmm.unitEdgeLength(15.0);
fmmm.newInitialPlacement(true);
fmmm.qualityVersusSpeed(FMMMOptions::QualityVsSpeed::GorgeousAndEfficient);
fmmm.call(GA);
GraphIO::write(GA, "C:/output.gml", GraphIO::writeGML);
return 0;
}
同一个文件不同的layout,layout算法可以在OGDF 官网上去参考