vtraag / leidenalg

Implementation of the Leiden algorithm for various quality functions to be used with igraph in Python.
GNU General Public License v3.0
596 stars 78 forks source link

'Graph' object has no attribute 'vcount' #58

Closed SruthiHarish closed 3 years ago

SruthiHarish commented 3 years ago

Hai, I have tried Leiden package. When running it with the famous 'karate club' network, it produced an error like Graph' object has no attribute 'vcount'. What will be the reason?????

import leidenalg
import igraph as ig
import networkx as nx

G = nx.karate_club_graph()
part = leidenalg.find_partition(G, leidenalg.ModularityVertexPartition)
vtraag commented 3 years ago

The object G is a networkx object, not an igraph object. In the most recent versions of igraph, you can obtain an igraph object using from_networkx: G2 = igraph.Graph.from_networkx(G). You can then apply leidenalg.find_partition to G2 instead of G.

SruthiHarish commented 3 years ago

Thank you... solved...