Where is the underlying implementation code for community_walktrap() of python_igraph?

When I was using community_walktrap, there was a big difference between directed graph and undirected graph. I want to see the implementation code. Where can I see it?

I think this piece of python code

calls this C++ code:

Those links point to the latest releases, so it could be your version is different.

community_walktrap() is supposed to ignore edge directions. If you have an example where this is not the case, please minimize it and post it here, so we can look at it.

Note that there are several way to convert a directed graph to undirected. Consider this graph:

If you simply ignore edge directions, you get:

This is what community_walktrap() effectively does, and this is what you get with the each mode of the as_undirected() method. However, the default mode used by as_undirected() is collapse, which gives us a very different graph:

This may be the reason why you are getting different results.

Note that community_walktrap() effectively adds up the weights of parallel edges, so in an unweighted directed graph reciprocal directed edges end up interpreted as edges with weight 2.

I will read it carefully. Thank you very much for your help.

I use the same set of data, like [1, 2], [2, 3]â€¦ There may also be duplicate edges, but Iâ€™m not going to worry about weights for now.

The graph was constructed using nx.Digraph() and nx.graph() respectively,

G = nx.DiGraph(); G.add_edge(1, 2); G.add_edge(2, 3); ...


converted to a â€ś.gmlâ€ť file and run community_walktrap(steps=6) , so my directed graph should look like Fig. 3, but my undirected graph looks like Fig. 3 and the result is quite different.

In addition, when I was testing the data set nx.les_lesables_graph (), converting it to a bidirectional graph and run community_walktrap(steps=6) is very different from the undirected graph.

G = nx.DiGraph(); G.add_edge(1, 2); ...

Once again, if you have an example where community_walktrap() produces a different result for a directed graph than the equivalent undirected one (created using .as_undirected('each')), please show it. Follow the guide here and make sure that the example is complete and minimal, i.e. remove all aspects of the code that are not necessary for demonstrating the issue (e.g. do not use NetworkX, construct the graph directly in igraph).