본문 바로가기

Robotics/Software Tech.

python for windows에 igraph 설치시 pycairo 설치방법


이전에 python에서 그래프로 데이터를 표현할 때 networkx를 썼었는데, networkx도 괜찮은데, igraph가 더 괜찮다고 해서 설치를 해봤다. 매뉴얼만 보면 어렵지 않다. installer를 이용해서 한큐에 딱 설치되면 좋겠지만.. 누군가 조금만 고생해주면 좋겠는데 말이지..ㅋㅋ 이 package가 다양한 package와 연동되서 돌아가기 때문에 좀 그런가보다..

어쨌든.. 설치는 아래와 같이..
igraph가 그래프를 그리는데 cario라는 라이브러리를 사용하는데

1. http://ftp.acc.umu.se/pub/gnome/binaries/win32/pycairo/1.8/ 에서 python 2.6 또는 2.7 버젼용 installer를 다운받아서 설치한다.

2. pycairo를 설치한 뒤에 수동으로 파일을 복사해줘야 하는것이 있다.
파이썬이 설치된 폴더중에 Lib\site-packages\cairo 폴더가 생성되는데, 여기에 몇가지 dll파일을 복사해야 한다.
http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/ 로 이동해서 몇개의 파일을 다운받아서 압축을 풀고, 그 파일내에 있는 dll파일들을 위 폴더로 복사만 해주면 된다.
다운로드는 아래에서..

1) http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/cairo_1.8.10-4_win32.zip
2) http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/fontconfig_2.8.0-2_win32.zip
3) http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/freetype_2.4.4-1_win32.zip
4) http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/libpng_1.4.3-1_win32.zip
5) http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/zlib_1.2.5-2_win32.zip
6) http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/expat_2.0.1-1_win32.zip

 dll을 복사해주고 난뒤에, 아래코드로 정상적으로 그래프가 그려져서 파일이 로딩되면 끝.

from igraph import *
g = Graph.Famous("petersen")
plot(g)

 


-------------------------
웹 검색을 하다가 NetworX와 igraph중에 어떤것이 더 좋은가에 대한 이야기가 있어서 발췌했다. (http://groups.google.com/group/networkx-discuss/browse_thread/thread/7597ca97abbb3f90 참조)

전체적으로 크게 차이가 없지만, 기능이나 성능을 따진다면 iGraph쪽, 문서나 다양한 예들, community활성화 정도등의 기반 support가 NetworkX가 더 활성화 되어있기때문에 iGraph보다는 NetworkX를 쓰는 사람이 더 많은 느낌..

- iGraph has some community detection algorithms implemented, while NetworkX does not. 

- iGraph's GraphML exporter included a more complete implementation of 

   the GraphML specification, meaning that if you have a graph with all sorts 

   of things labeled and weighted, it might be easier to export all this data 

   into GraphML with iGraph. 
 

Another difference between the two packages (and the reason I prefer 

NetworkX), is that NetworkX is well-documented, and has a fairly active 

community that can answer questions.  I found that the python version of 

iGraph was not very well documented.  Also, NetworkX is written more in 

python than iGraph.  If you are using the python version of iGraph, then you 

will usually not be able to read the source code in python--you will just 

run into a binding.