'igraph clusters from dataframe
I'm trying to move a codebase from R to python and I need to move the R function from igraph over from the following:
g <- igraph::graph_from_data_frame(edges)
clusters <- igraph::clusters(g)
To an equivalent in python, however when I try:
edges = pd.DataFrame({"from":[0,1,2,4], "to":[1,2,3,5]})
g = igraph.Graph.DataFrame(edges)
print(g.clusters())
I get each of the elements of the graph individually.
I don't think this is due to the clusters call being the wrong thing because if I do the following:
graph = igraph.Graph([(0,1), (1,2), (3,4)])
print(graph.clusters())
I get two distinct clusters. I think it must therefore have something to do with the way I'm creating the graph from the dataframe?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|


