afternone / CommunityDetection.jl

Community Detection in Julia
Other
20 stars 3 forks source link

Documentation #2

Open anuraag94 opened 5 years ago

anuraag94 commented 5 years ago

Is there full documentation I can access via ?CommunityDetection or something in the repl? For my application, I'd like to calculate the Louvain modularity for a partition made on a weighted graph, and then while keeping the partition the same, the modularity for the unweighted version of the original weighted graph. I'm trying to figure out how to do this, any help would be appreciated!

Update: Trying to run the test code in the readme, and I'm unable. Do you know if this works with Julia 1.0?

afternone commented 5 years ago

The signature of the modularity function is

function modularity{V,T<:Real}(graph::AbstractGraph{V}, membership::Vector{Int}, weights::Vector{T})

So, you can calculate the modularity without considering weights as follows:

modularity(graph, membership, ones(num_edges(graph)))

This package should work fine at 0.6, and there have been many changes from 0.6 to 1.0, so there may be some problems with julia 1.0.

anuraag94 commented 5 years ago

Hmm, it might be because of 1.0, it fails on precompile. Not very keen on downgrading the rest of my code to 0.6, but if I can use this the way I need to, I'll give it a shot.

To clarify, does the modularity function calculate the optimized modularity according to the two-phase Louvain method? What I'd like to do is get the Louvain-optimized modularity for the weighted graph, then, using the same community structure that Louvain optimized for on the weighted graph, calculate the modularity on the unweighted graph. NB: this won't necessarily be the Louvain-optimized modularity on the unweighted graph. I'm not sure if this is possible with this package, but if you have any ideas I'd love to hear them.

afternone commented 5 years ago

The modularity function only calculates the modularity of a given partition of the graph,and does not perform the optimization process. So this function is what you want. For example, you have a graph and its community structure (i.e. parameter membership), you can calculate the modularity of the given community structure of your graph by this way:

modularity(your_graph, your_community_structure) # weights default to 1.0 for all edges