Given an undirected graph $$$G=(V,E)$$$, where $$$V$$$ is the set of graph nodes, and $$$E$$$ is the set of graph edges. Non-overlapping community detection for the graph $$$G=(V,E)$$$ is the task of the partitioning of the set $$$V$$$ of all graph nodes into $$$n \geq 1$$$ mutually disjoint non-empty sets called communities, $$$$$$C_1, C_2, \ldots, C_n \subseteq V,$$$$$$ whose union is $$$V$$$. In other words,
As a consequence, every graph node belongs to exactly one community.
Naturally, the partitioning can be done in many ways. We will evaluate the quality of partition based on the value of modularity measure.
Modularity measure
Given an undirected graph $$$G=(V,E)$$$ without loop edges and its partition into a set of communities, $$$C=\{C_1,C_2,\ldots,C_n\}$$$. The quality of the partition will be measured by the modularity $$$Q$$$, defined by the following formula:
$$$$$$ Q = Modularity(C) + Regularization(C) $$$$$$
$$$$$$ Modularity(C) = \sum_{c \in C} \left( \frac{|E^{in}_c|}{|E|} - \left(\frac{2|E^{in}_c| + |E^{out}_c|}{2|E|}\right)^2 \right) = \sum_{c \in C} \left( \frac{|E^{in}_c|}{|E|} - \left(\frac{\sum_{v \in c} deg(v)}{2|E|}\right)^2 \right), $$$$$$
$$$$$$ Regularization(C) = 0.5 \cdot \left( \frac{1}{n} \sum_{c \in C} density(c) - \frac{1}{|V|/n} \right) $$$$$$
$$$$$$ density(c) = \left. \begin{cases} 1 & \text{if } |c| = 1;\\ \dfrac{|E_c^{in}|} {\dfrac{1}{2} \,|c|\,(|c| - 1)} & \text{if } |c| \ge 2. \end{cases} \right. $$$$$$
where:
$$$E^{in}_c = \bigl\{ (v_i, v_j) \in E: v_i \in c,\; v_j \in c,\; i \gt j \bigr\};$$$
$$$E^{out}_c = \bigl\{ (v_i, v_j) \in E: v_i \in c,\; v_j \notin c \bigr\};$$$
It is known that
Task statement & Competition rules
On the complexity of community detection
The number of all possible partitions of an $$$n$$$-element set is known as the Bell number $$$B_n$$$. It is known that $$$B_n$$$ grows exponentially with $$$n$$$ (namely, $$$\log B_n \sim n \log n$$$). Thus, it is infeasible to find the best partition of a large graph by brute-force.
It is also known that, in the general case, the task of finding the set of communities with maximum modularity is NP-hard.
We hope that you can find an efficient approximate algorithm for this problem. Many strategies can be used to solve this problem, and an algorithm can have combinatorial, optimization, heuristical, or any other nature. The algorithm itself is not a deliverable; only the final value of modularity is counted.
Examples
For a given partition of graph nodes into communities, modularity reflects the concentration of edges within communities compared with a random distribution of edges between all nodes. Thus, from the viewpoint of modularity maximization, it is beneficial to make a graph partition such that
Example 1
In this picture, every graph node forms a singleton community. The modularity for this partition is negative, $$$Modularity \approx -0.153$$$.
Example 2
In this picture, we have one community containing all graph nodes. The modularity for this partition is zero, $$$Modularity = 0$$$.
Example 3
In this picture, the graph is partitioned into two communities. The modularity for this partition is $$$Modularity \approx 0.281$$$.
Example 4
The picture illustrates a graph with an optimal partition of its nodes. The modularity value for this partition is $$$Modularity \approx 0.420$$$. A higher modularity value is not reachable for this graph.
Every input graph $$$G=(V,E)$$$ is defined by the set of its edges. It is given in text file format, where every line represents a graph edge, e.g. the following input defines a graph with 6 nodes and 6 edges:
0 1
0 2
0 3
1 2
1 4
3 5
We guarantee the following assumptions about the input format:
The output should be given in text file format where every line contains the list of all graph nodes of some community, e.g. the following output defines three communities:
0 1 2
4 5
3
The output will be verified by the verification system, and the modularity measure will be computed for it.
In case some graph node is assigned to more than one community, or some graph node is not present in the output file, the result will be rejected by the verification system.