简体   繁体   中英

cairocffi and plotting (for Leiden algorithm)

I am new of cairo library in python so I hope you can provide some info as I have not found a lot on the web. I am trying to use an algorithm to determine the communities in my (not connected) network:

import igraph as ig
import leidenalg as la

G = nx.karate_club_graph()
partition = la.find_partition(G, la.ModularityVertexPartition)
ig.plot(partition)

The code above returns an error that asks to install Cairo or . I installed it, then, and tried with the following code:

import cairocffi as cairo

G = nx.karate_club_graph()
G2 = ig.Graph.from_networkx(G)
partition = la.find_partition(G2, la.ModularityVertexPartition)
ig.plot(partition)

and now I am getting the following error:

OSError: no library called "cairo-2" was found
no library called "cairo" was found
no library called "libcairo-2" was found
cannot load library 'libcairo.so.2': dlopen(libcairo.so.2, 2): image not found
cannot load library 'libcairo.2.dylib': dlopen(libcairo.2.dylib, 2): image not found
cannot load library 'libcairo-2.dll': dlopen(libcairo-2.dll, 2): image not found

I have no idea on how to plot a graph using cairo. What I would like to do is to apply leiden algorithm (even visually).

cairo is a C library. cairocffi is one Python interface to it. You have installed cairocffi , but not cairo . Be sure to install cairo as well with your system's usual package manager, as described in the cairocffi docs:

https://cairocffi.readthedocs.io/en/stable/overview.html#installing-cffi

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM