Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

It is possible to set 2 options for one of FindGraphCommunities's methods "Modularity". They are "Weighted" and "StopTest".

The question is how can one use the second option "StopTest"? What values/pure functions does it take?

share|improve this question
    
Where do you find this second option? When I look at FindGraphCommunities I only see the Method option. –  bill s Jul 3 '13 at 18:05
    
@bill s, there's a special syntax to set options: Method->{MethodName, OptionName->Option}. So the user can provide some random string for OptionName to produce an error message. This error message says "OptionName is not in {"Weighted", "StopTest"}". So that is the way to find out what are the options available for that method. –  iav Jul 4 '13 at 7:50
    
I see. Oddly, I get the same error message even if I have OptionName->"Weighted" or OptionName->"StopTest". So it's not clear these options are really implemented. Have you been able to do anything with them? –  bill s Jul 4 '13 at 8:01
    
sorry, I may have not put it as clear as I should. OptionName is a placeholder for "Weighted". Try for ex. Method->{"Modularity","Weighted"->True} or {"Modularity","Weighted"->False}. This should produce different results in general for weighted graphs (and no errors). –  iav Jul 4 '13 at 8:23
    
So you could guess that Weighted->False analyzes a weighted graph as if it were unweighted. Not sure about StopTest. If you find any documentation about these, please post so we can all see it. –  bill s Jul 4 '13 at 16:45

1 Answer 1

up vote 4 down vote accepted
+50

Method "Modularity" starts with each vertex in its own community and then iteratively merges them to maximize the proportion of edges contained within communities minus the expected proportion that would be in the communities if the edges were randomly placed.

Details here: http://en.wikipedia.org/wiki/Modularity_(networks)

The "StopTest" option expects a boolean-valued function that takes the graph as the first parameter and the list of vertex communities for the current iteration as the second parameter. You can, for example, use the stop test to halt the merging of communities early if there is a specific number of communities that you want to be returned. Using an example from the documentation that contains three communities with default options, we can stop it early to find five communities.

g = Graph[{1 \[UndirectedEdge] 2, 2 \[UndirectedEdge] 3, 
   1 \[UndirectedEdge] 3, 3 \[UndirectedEdge] 4, 
   4 \[UndirectedEdge] 5, 7 \[UndirectedEdge] 6, 
   8 \[UndirectedEdge] 6, 5 \[UndirectedEdge] 7, 
   7 \[UndirectedEdge] 8}]

FindGraphCommunities[g, 
 Method -> {"Modularity", "StopTest" -> (Length@#2 == 5 &)}]
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.