Structural and Algorithmic Properties of 2-Community Structures

We investigate the structural and algorithmic properties of 2-community structures in graphs introduced recently by Olsen (Math Soc Sci 66(3):331–336, 2013). A 2-community structure is a partition of a vertex set into two parts such that for each vertex the numbers of neighbours in/outside its own part and the sizes of the parts are correlated. We show that some well studied graph classes as graphs of maximum degree 3, minimum degree at least |V|-3\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$|V|-3$$\end{document}, trees and also others, have always a 2-community structure. Furthermore, a 2-community structure can be found in polynomial time in all these classes, even with additional request of connectivity in both parts. We introduce a concept of a weak 2-community and prove that in general graphs it is NP-complete to find a balanced weak 2-community structure with or without request for connectivity in both parts. On the other hand, we present a polynomial-time algorithm to solve the problem (without the condition for connectivity of parts) in graphs of degree at most 3.


Introduction
The research around community structures can be seen as a contribution to the wellestablish research of clustering and graph partitioning.The partition of graphs have been intensively studied with various measures to evaluate their quality, see e.g.[2,7,14,17,19] for an overview.
A standard abstract model for any kind of social networks such as Facebook or Linkedin is a graph, in which vertices are members of the network and edges are relationships between members.In such model 'a community' intuitively corresponds to a subgraph that has 'more relationships' inside the subgraph than outside of it.More generally, 'a community structure' corresponds to a partition of a graph into communities.
There have been several attempts to define the concept of communities formally, a good introduction including the motivation can be found in [1,6,11,18,20].One of the first definitions of a community was motivated by the searching links in web graphs and introduced by Flake et al. [13].It defines a community as a set of vertices C such that each vertex in C has at least as many neighbours inside C as outside.The same notion called an 'alliance in graphs' were introduced by Kristiansen et al. [16] and investigated further in various papers.The concept of communities and community structures have received a significant attention in further research where also some modified definitions of communities were studied e.g. the difference between the number of outside and inside neighbours should be larger than a given constant, the community should also be a dominating set, see e.g.[4,5,15] for overview and further references.
In this paper we study the structural and complexity problems of the recent definition of a community structure that reflects the sizes of communities too [10,11,18].This new approach to communities is supported by the practical experiments showing the importance of capturing the sizes of communities for a better description of their properties [18].
The general concept of a community structure does not put any restriction on the number of communities.This paper focuses on a partition with two communities where the problems are already appealing.The presented techniques offer some possibilities for an extension to a larger number of communities.Informally, a 2-community structure is a partition of the vertex set into two parts A, B such that for each vertex, say from part A, the ratio 'the number of neighbours in part A' over the size of A (excluding the vertex itself) is at least as large as 'the number of neighbours in part B' over the size of B. To generalise, in a k-community structure, the ratio must be valid for every two communities.We also introduce a weak community structure in which the vertex itself contributes to the ratio.The ratio condition in the latter definition is weaker, but it reflects the reasonable requirement that each member should be considered as a part of its own community (see Sect. 2 for the technical details).Even if there are minor differences between the definitions, the structural and complexity results for the two problems are very different as it is presented in this paper.Both definitions are relevant to describe the community structures, the choice depends on the suitability of the model.
We also study the 2-communities problems with additional constraints such as connectivity or equality of sizes for both parts (a balanced partition).The connectivity request corresponds to the essential condition that each member in the community should 'indirectly know' all members in its own community, where the 'indirectly know' relation corresponds to a path between two vertices in the graph.The study of balanced communities is motived by the practical interest for equal size of the communities.In general, the balanced graph partitions are well studied, e.g.due to its applications in the divide-and-conquer algorithms, see e.g.[8].In the balanced partition problem, which can be seen as a generalisation of the bisection problem to any given number of parts, the goal is to minimise the number of edges between partitions.It is known that the problem cannot be approximated within any finite factor in polynomial time in general graphs and it remains APX-hard even on trees of constant maximum degree [12].It demonstrates that some graph partitions problems that are related to e.g.balanced communities are hard to solve even for restricted graph classes and indicates hardness of various problems related to a community structure too.Hence all positive results in community structure problems would be important to get better understanding of the differences between community and partition problems.
Furthermore, a community structure is in fact a graph partition with a restricted number of edges between parts, therefore the new results for communities may find applications in the areas similar to a graph partition such as parallel-computing, VLSIcircuit design, route planning [9] and divide-and-conquer algorithms [21].
There are only a few results related to this new definition of a community.Olsen [18] proved that a community structure (without the condition on the exact number of communities) can be found in polynomial time in any graph with at least 4 vertices, except a star.Recently, Estivill-Castro et al. [11] claimed that the problem to find a k-community structure with restriction to all communities to be connected and equal size is NP-complete in general graphs, but polynomially solvable in trees.In [18] Olsen also proved that it is NP-complete to decide, whether there is a community structure in a graph in which a given set of vertices is included in a community.

Our contribution
The following overview summarises our results achieved in this paper.All considered graphs are of size at least 4 and are not stars.If a 2-community structure with certain properties exists for a graph class, then it exists for all the graphs from the class.
(i) trees -a connected 2-community structure exists and can be found in linear time (Theorem 1), -there are trees with a balanced 2-community structure, but without a connected balanced weak 2-community structure (Remark 2), (ii) graphs of maximum degree 3 -a connected 2-community structure exists and can be found in polynomial time (Theorem 2), -a balanced weak 2-community structure exists and can be found in polynomial time (Theorem 6), -there are graphs without a balanced 2-community structure (Remark 1), -there are graphs with a balanced 2-community structure, but without a connected balanced weak 2-community structure (Remark 2) (iii) graphs of minimum degree (|V | − 3), complements of bipartite graphs, graphs with minimum degree where c is the size of an inclusion-wise maximal clique in the graph -a connected 2-community structure exists and can be found in polynomial time (Theorems 3, 4, 5) (iv) graphs of bounded tree-width -there are graphs without a balanced 2-community structure (Remark 1), but to decide whether such a structure exists and if it exists, find it, can be done in polynomial time (Remark 3) Estivill-Castro et al. [10] proved that the problem of finding a balanced 2-community structure is NP-complete in general graphs.In Sect. 4 we show that the same result also holds for a weak community, even with additional constraint of connectivity for both parts.We also present a shorter proof of the known NP-complete result for a balanced 2-community structure in general graphs based on an alternative definition of community structure [4], which also implies NP-completeness for a connected balanced 2-community structure.
The paper is structured as follows.In Sect. 2 we introduce formally some notations and definitions of studied problems.In Sect. 3 we show that in some well-studied graph classes a 2-community structure always exists and can be found in polynomial time, even with additional request for connectivity in both parts.In Sect. 4 we focus on the balanced 2-community structure and present the structural and algorithmic results in general graphs and some graph classes.Conclusions and open problems are provided in Sect. 5.

Preliminaries
In the paper, all considered graphs are simple, undirected and connected.Let G = (V, E) be a graph.For a vertex v ∈ V , let d(v) be the degree of the vertex v and for any subgraph H of the graph G let N H (v) be the set of the neighbours of v in H , For a given partition of V into two parts (a 2-partition), let an in-neighbour of v (resp.out-neighbour) be a neighbour in its own part (resp.out of its part) and d in (v) (resp.d out (v)) denote the number of in-neighbours of v (resp.out-neighbours).For a graph G and a subset of vertices are connected and it is balanced if the sizes of C 1 and C 2 differ by at most 1.The cut size of a 2-partition is the number of edges that have end vertices in the different parts of the partition.A graph is said to be of minimum (resp.maximum) degree k if any vertex of the graph has degree at least (resp.at most) k.A pendant vertex of G is any vertex of degree 1.A star is a complete bipartite graph K 1, for any Now we introduce Olsen's definition of a k-community structure from [18].v Fig. 1 A weak 2-community structure of a graph (presented by the colours black and white) in which the vertex v does not satisfy the condition of a 2-community structure but satisfies the condition of a weak 2-community structure from Definition 1 and ∀v ∈ C i , ∀C j ∈ , j = i, the following holds For a weak k-community structure, the condition above is replaced by a "weaker" condition Notice that a k-community structure is obviously a weak k-community structure since but the opposite is not true (see Fig. 1).In this paper we investigate a community structure for a fixed number of two communities and also study some variants of the 2-Community problem:

2-Community
Obviously, if G has a 2-community structure, it must have at least 4 vertices and be non-isomorphic to a star which we assume in the paper even without explicitly mentioning that in some informal parts.
In the Weak 2-Community problem we are looking for a weak 2-community structure in a graph where the condition (1) is replaced by Adding the balanced condition to the 2-Community problem, we obtain the Balanced 2-Community problem introduced by Estivill-Castro et al. [10].Similarly we can define the Balanced Weak 2-community problem.
The additional constraint which asks for subgraphs induced by each part of the partition to be connected is a natural condition useful for the problems related to the connectedness.The Connected 2-Community problem is to decide if a graph has a connected 2-community structure, i.e. a 2-community structure {C 1 , C 2 } such that the subgraphs induced by C 1 , C 2 are connected.We can define analogous problems for weak and balanced versions.

Connected 2-Community Structures in Some Graph Classes
In this section we show that if a graph has certain structural properties, then it has a connected 2-community structure which can be found in polynomial time.More precisely, we prove that such a statement is valid for trees and graphs of high minimum or low maximum degrees.
Theorem 1 Every tree with at least 4 vertices (except a star) has a connected 2-community structure that can be found in linear time.
Proof Let G = (V, E) be a tree not isomorphic to a star.We prove that there exists an edge e ∈ E such that two connected components of G \ e form a 2-partition which is a connected 2-community structure.
Let e = {u, v} be an edge in E such that d(v), d(u) ≥ 2 (due to the assumption about G such an edge e must exist).Consider a partition {X u , X v } of V with X u (resp.X v ) be the set of vertices of the connected component of G \ e containing u (resp.v).
First we notice that only one of the vertices u and v may not satisfy the condition (1).If this is not true then If both vertices u and v satisfy the condition (1), then {X u , X v } is obviously a 2-community structure.If not, then without loss of generality, let the vertex u satisfy the condition (1) and v do not.Then the Update procedure is repeated and if no update is possible, a modified partition {X u , X v } is already a 2-community structure as it is shown later.
The Update procedure: , then v must already satisfy the condition (1) in the partition {X u , X v } at the beginning of the Update procedure.
Hence from now we suppose that v has at least one neighbour of degree at least 2 excluding u.In the following we show that there exists j, 1 ≤ j ≤ d(v) − 1, such that d(v j ) > 1 and the vertex v satisfies the condition (1) in the partition {X j , V \ X j }.Indeed, suppose that for all j, 1 ≤ j ≤ d(v) − 1, with d(v j ) > 1, this is not true.Notice that for each such j and the partition {X Moreover, for any j, since G is not a star.Recall that v doesn't satisfy the condition (1) in the partition Summing ( 3), ( 4) and ( 5) together, we obtain Hence, there exists i, Then, relabel u := v and v := v i and return to the beginning of the Update procedure.
Each time the labels of u and v are updated, the size of X u strictly increases by at least one, hence the whole process always terminates.A final partition at the end of the process is a connected 2-community structure because both partitions correspond to two connected components of a tree obtained by removing an edge.
Notice that finding such an edge can be done in O(|V |) operations.First, in constant time fix an edge e = {u, v} such that d(v), d(u) ≥ 2.Then, consider G \ e as a union of two trees T u and T v , where T u is a tree on the vertex set X u rooted in u (and similarly for T v on X v rooted in v).For each vertex w of G calculate recursively the size of the subtree of T u (or T v ) rooted in w which can be done in time O(|V |).Finally, using the sizes of the subtrees, check if {X u , X v } corresponds to a 2-community structure and if needed, update X u , X v according to the algorithm.The number of such updates is clearly at most |E|.Since G is a tree, the repetition of the Update procedure finishes with a connected 2-community structure in O(|V |) time.
Very recently, Estivill-Castro et al. proved in [11] the same result using different methods.Our approach is more structural and the proof for the existence of an edge that connects two communities results directly in a linear time algorithm.Now we investigate graphs that may contain cycles but that still have low densities, namely the graphs of maximum degree 3. First, the restrictions on the size of partitions are discussed to ensure the vertices fulfil the condition (1) of a 2-community structure.
Then each vertex of degree 3 in G with at most one out-neighbour fulfils the condition (1) of a 2-community structure.
Furthermore, if for some i ∈ {1, 2}, It is clear that the condition (1) is true for each vertex which has only neighbours in its own part.Firstly, suppose the vertex v from C i , i ∈ {1, 2} has exactly one out-neighbour.
Since 1) is fulfilled for the vertex v. Now suppose that for i ∈ {1, 2} there is a vertex v ∈ C i with exactly two outneighbours and

3
. This corresponds to the condition (1) for the vertex v.
Then each vertex of degree 2 in C 1 with at most one out-neighbour fulfils the condition (1) of a 2-community structure.
If the partition is balanced, then each vertex of degree 2 in G with at most one out-neighbour fulfils the condition (1).
Obviously, any vertex of degree 2 with no neighbours out of its own part fulfils the condition (1).Moreover any vertex of degree 2 in C 1 with only one out-neighbour satisfies 1 , and hence the vertices of degree 2 from both parts with exactly one out-neighbour satisfy the condition (1).Proof Let G = (V, E) be a graph with the given properties.If G is a tree, take a pendant vertex u ∈ V and let v ∈ V be its neighbour.If G is not a tree, let {u, v} be an edge of a cycle in G. Since G is not isomorphic to a star such an edge must exist.

If the partition has one of the properties (i)-(iii) where only specified vertices may have out-neighbours (the other ones have only in-neighbours
Initially, put into C 1 the vertices u, v together with their pendant vertices, if it is applicable.If there is a vertex z of degree 2 adjacent to u and v, update The algorithm keeps connectivity of G[C 1 ] and G[C 2 ] and extends C 1 either by transferring vertices from C 2 to C 1 or relabelling a suitable connected part of the graph until n−1 Option 2 If the subgraph induced by C 2 \ {w} is disconnected (w must be of degree 3), then denote by A, B the vertex-sets of two connected induced subgraphs of G on C 2 \ {w}.Depending on the size of A, the following update is executed.
and put after the execution of the option 1 or 2, then the Update procedure halts, otherwise the Update Procedure is repeated again.
By our construction, the partition {C 1 , C 2 } remains connected during each run of the Update procedure.
Each time the Update procedure is executed, the size of C 1 strictly increases, hence the algorithm always terminates.
At the end of the algorithm n−1 Proof Let G = (V, E) be a connected graph of maximum degree 3 on n vertices, n ≥ 4, not isomorphic to a star.Due to Lemma 4, a connected partition , can be found in polynomial time.Let {C 1 , C 2 } be such a partition and notice that the vertices that do not satisfy the condition (1) can be split into two categories: then all the vertices of degree 3 in C i with two out-neighbours, (B) if the partition is not balanced, then all the vertices of degree 2 in the larger part with one out-neighbour.
The algorithm starts with the initial partition {C 1 , C 2 } and then the Improvement Procedure (consisting in three stages) can be applied several times.The procedure transfers step-by-step all the vertices of degree at least 2 (with exactly one neighbour in its own part) between C 1 and C 2 or relabel the sets, until all the vertices satisfy the condition (1).Since the initial partition is connected, transferring vertices with such a property never disconnects any part of the partition.The Improvement Procedure:  and there is a vertex u ∈ C 1 with two out-neighbours, update Notice that each iteration of Stage 2 decreases the cut-size by at least one.The Improvement Procedure: Stage 3 (Category (B) vertices) If the partition is not balanced, the vertices of degree 2 with one out-neighbour must be transferred from the larger part to the smaller part.
2 and there exists a vertex u of degree 2 in C 2 with one neighbour in C 1 , update Each iteration of the while loop in Stage 3 doesn't increase the size of the cut.In the end of Stage 3 if the final partition doesn't have a 2-community structure then a vertex of the category (A) must exist in the partition.In that case, Stage 1 or 2 must be executed before entering Stage 3 again, hence the cut-size is decreased by at least one.Notice that Stage 3 may again create vertices of the category (A) even if they didn't exist before entering Stage 3.
It is easy to see that the algorithm always terminates.Each iteration of the while loop in Stage 1 (resp.Stage 2) decreases the cut-size by at least one.In Stage 3 each iteration of the while loop increases the size of the smaller part by at least one and halts before or when the partition is balanced.Following the construction, if the Improvement Procedure needs to be run again, it must first run through Stage 1 or 2 which decreases the cut-size by at least one.Moreover, the algorithm clearly runs in polynomial time.
Let's discuss the correctness of the algorithm.Suppose the algorithm terminates with the final partition {C 1 , C 2 }.Due to the conditions inside the algorithm, n−1 Initially, the partition is connected and remains so after each stage, hence the final partition is connected too.
Then necessarily, each vertex of degree 1 satisfies the condition (1) since it must be in the same part as its neighbour.Now there are two options: -If the final partition is balanced then all vertices of degree 2 and 3 may have at most one out-neighbour (otherwise the Improvement Procedure could be applied again), hence the final partition {C 1 , C 2 } is a 2-community structure due to Lemma 3(ii).-If the final partition is not balanced, then the partition must have the properties described in Lemma 3(i) or (iii) (otherwise, one of Stages 1-2 could be applied again).Hence the final partition {C 1 , C 2 } is a 2-community structure.
Now we investigate the problem of the existence and finding of a connected 2community structure in dense graphs.We prove that any graph G = (V, E) of minimum degree |V | − 3 has a connected 2-community structure which can be found in polynomial time.

Lemma 5 If the complement of the graph G is 2-colourable (using each colour for at least 2 vertices), then G has a connected 2-community structure which can be found in polynomial time.
Proof Let G = (V, E) be a graph such that its complement G is 2-colourable.Fix a 2-colouring of G (with at least 2 vertices for each colour) and define {C 1 , C 2 } as a partition of V , where each part corresponds to one colour in G. Obviously, Notice that the induced subgraph on the vertex set C 1 (resp.C 2 ) is a clique.Therefore, any vertex v ∈ V satisfies the condition (1) and the partition {C 1 , C 2 } is a 2-community structure.Since a 2-colouring can be found in polynomial time, the 2-community structure {C 1 , C 2 } too.Obviously, the partition is connected.This result directly implies the following theorem: Theorem 3 The complement of any bipartite graph (with at least two vertices in each part) has a connected 2-community structure which can be found in polynomial time.
Theorem 4 Any graph (except a star) of minimum degree (n − 3), n ≥ 4, where n is the order of the graph, has a connected 2-community structure which can be found in polynomial time.
Proof Let G be a graph of size n and of minimum degree (n − 3) (except a star), n ≥ 4, and G be the complement of G. Notice that G is of degree at most 2. If G doesn't contain an odd cycle, then there exists a 2-colouring of G with at least 2 vertices for each colour.In such case, a connected 2-community structure can be found in polynomial time due to Lemma 5. Now let A be the union of all vertices belonging to an odd cycle in G and denote by only possible for a star or a graph with 3 vertices).Obviously, every such 2-colouring can be found in polynomial time.Finally we show that the partition {C 1 , C 2 } is a connected 2-community structure.
All vertices of C 2 satisfy the condition (1) in If c ≤ |V | − 2, let C be the inclusion-wise maximal clique in G and take {C, V \ C} as a partition.Obviously, the size of both parts is at least 2. C is a clique, hence the condition (1) is trivially satisfied for all vertices in C. If a vertex u ∈ V \ C has a neighbour in C, then hence the condition ( 1) is satisfied for all vertices u ∈ V \ C with a neighbour in C.
The rest of vertices in V \ C trivially satisfy the condition (1) since they do not have a neighbour in C. Now we prove that the partition {C,

Balanced 2-Community Structure
In this section we study complexity of the problems related to a balanced 2-community structure.First we prove that every graph of maximum degree 3 has a balanced weak 2-community structure that can be found in polynomial time.The structural properties of low-degree graphs are crucial to obtain such a result.In general graphs, the Balanced Weak 2-community and Balanced 2-community problems are NP-complete as it is shown further in the section.The latter result is contained as the main result in [10], an alternative shorter proof is presented in this section.Both NP-completeness results are extended to a connected balanced 2-community structure.
Remark 1 Due to Theorem 2, every graph of maximum degree 3 has a 2-community structure, but it is not true for a balanced 2-community structure, see Fig. 2. The graph is obtained by linking three "cross gadgets".First notice that if a balanced 2-community exists for the graph, then all vertices of each cross gadget must be in the same part.Indeed, each vertex of such community structure must have two neighbours in its own part.But on the other hand, this graph is impossible to split into two balanced parts without splitting a cross gadget.
Nevertheless, if we focus on a weak community, a balanced weak 2-community always exists in graphs of maximum degree 3, as it is shown in the following theorem.
Theorem 6 Any graph of maximum degree 3 with at least 4 vertices has a balanced weak 2-community structure.Moreover, such a community structure can be found in polynomial time.
Proof Let G = (V, E) be a connected graph of maximum degree 3. First notice that in any balanced partition of V : Fig. 2 A cross gadget and a graph of maximum degree 3 without balanced 2-community structure Fig. 3 A tree of maximum degree 3 in which any balanced 2-community structure (or even balanced weak 2-community structure) is disconnected (an example of a balanced 2-community structure is presented by the black and white colours) -each vertex of degree 1 fulfils the condition (2), even if its neighbour is not in its own part, -each vertex of degree 2 or 3, which has at least one neighbour in its own part, satisfies the condition (2).Therefore, the only vertices which may not satisfy the condition (2) are vertices of degree 2 or 3 which have no neighbour in their own part.
Choose any balanced partition {C 1 , C 2 } of G and repeat the following steps (S1)-(S2) until it is possible: (S1) If both parts contain a vertex of degree 2 or 3 that has no neighbour in its own part (say If there is only one partition that contains a vertex v of degree 2 or 3 that has no neighbour in its own part (without loss of generality suppose v ∈ C 1 ), then choose a vertex w ∈ C 2 such that w has at least one neighbor in C 1 and update: First notice that if case (S2) occurs, such a vertex w always exists since the graph is connected.
Moreover, the partition remains balanced after each step (S1) or (S2).Besides, the cut size between the partitions C 1 and C 2 always decreases (by at least 2 in case (S1), by at least 1 in case (S2)) so after a finite number of iterations (bounded trivially by O(|V | 2 ), every vertex of degree 2 or 3 has at least one neighbour in its own part.Hence, the algorithm returns a balanced weak 2-community structure.
Remark 2 Notice that Theorem 6 cannot be extended to a connected case.There exist graphs of maximum degree 3 in which every balanced weak 2-community structures is disconnected, see Fig. 3 as an example.
Remark 3 It can be observed that the Balanced 2-community problem (hence also Balanced Weak 2-community) is polynomially solvable for graphs with bounded tree-width.Such result follows directly from [3] where the t-Decomposition problem closely related to communities was studied.The input to the t-Decomposition problem is a graph G = (V, E), an integer-valued function t = t (n) such that 0 ≤ t (n) ≤ n for every n ∈ IN, and two functions a, b : In order for {V 1 , V 2 } to be a balanced 2-community structure with and analogously for every . Thus, Balanced 2-community can be condidered as the t-Decomposition problem for selected values of the functions t, a, b.The conditions for Balanced 2-community can be transformed to the conditions of the t-Decomposition problem where t Since the t-Decomposition problem was proved to be polynomial-time solvable for bounded tree-width in [3], we can conclude the same result for the Balanced 2-community problem.Notice that the result cannot be extended to a connected case for all graphs, see a tree on Fig. 3 as a counterexample.Now we focus on the problem of Balanced 2-community in general graphs.
In [8] it has been proved that to find a connected balanced partition without any additional constraints is an NP-complete problem in general graphs.We prove similar results for Balanced Weak 2-community and Balanced 2-community and their connected variants.To show that Balanced Weak 2-community is NPcomplete, we use a reduction from the Balanced Co-Satisfactory Partition problem, proved to be NP-complete in [5].
The problems is defined as follow: Balanced Co-Satisfactory Partition Input : A graph G = (V, E) on an even number of vertices.Question : Is there a balanced partition Proof The problem is clearly in NP.In the following we define a polynomial-time reduction from Balanced Co-Satisfactory Partition to Balanced Weak 2-community.Let G be a graph on an even number n of vertices as an instance of Balanced Co-Satisfactory Partition, and let G, the complement of G, be an instance of Balanced Weak 2-community.If G admits a balanced cosatisfactory partition be the number of in-neighbours (resp.out-neighbours) of v in G.Then, the following holds din , which is the condition (2) for a balanced partition.Conversely, any balanced weak 2-community in G is a balanced co-satisfactory partition in G.
The proof of the NP-completeness of Balanced Co-Satisfactory Partition in [5] is based on the graphs G = (V, E), where V = F ∪ T ∪ V 0 with some additional properties: F and T are independent sets, there are no edges between T and V 0 , and there is a vertex f ∈ F that is not adjacent to any vertex of V 0 .Any balanced cosatisfactory partition {C 1 , C 2 } of V must have the following structure: C 1 = F ∪ S and C 2 = T ∪ (V 0 \ S) where S ⊆ V 0 .If G is an instance of Balanced Weak 2-community (constructed following the proof of Theorem 7), one can see that C 1 is connected since f is adjacent to all vertices in F ∪ S and C 2 is connected since T is a clique and every vertex of T is adjacent to every vertex of V 0 \ S. Hence we can conclude that even the connected version of Balanced Weak 2-community is NP-complete.
Theorem 8 Connected Balanced Weak 2-community is NP-complete.
Estivill-Castro et al. [10] have shown that Balanced 2-community is NPcomplete by constructing a reduction from a variant of the Clique problem.We propose a shorter alternative proof which is also valid for the Connected Balanced 2-community problem.The proof is based on the NP-complete problem Balanced Satisfactory Partition which was introduced by Bazgan et al. [4] as follows: Balanced Satisfactory Partition Input : A graph G = (V, E) on an even number of vertices.Question : Is there a balanced partition 2 ?It can be proved that these two problems are in fact equivalent when the number of vertices is even.
Lemma 6 Let G = (V, E) be a graph with n vertices.Consider a partition {C 1 , C 2 } of V and v ∈ C 1 .Then the following assertions are equivalent: Note Notice that the third assertion in Lemma 6 is the condition (1) of a 2-community structure.
Lemma 7 Let G = (V, E) be a graph with an even number n of vertices and {C 1 , C 2 } be a balanced partition of V .Then for any vertex n−1 d(v).Now we need to show that for every vertex v ∈ V, d in (v) ≥ 1 2 d(v).Suppose by contradiction that there exists a vertex v ∈ V that does not satisfy the inequality that is First, notice that 1 2 d(v) − |C 1 |−1 n−1 d(v) = 1 2(n−1) d(v) < 1, which means that there is at most one integer number between |C 1 |−1 n−1 d(v) and 1 2 d(v).Moreover, d(v) cannot be even, since otherwise d (v)  2 would be a whole number and thus d in (v) could not be an integer number.Then d(v) is odd and let d(v) = 2 p + 1 for some integer p.We arrive to a contradiction by showing that p < d in (v) < p + 1 2 .Notice that d(v (v).Then necessarily d in (v) ≥ 1 2 d(v) for every vertex v ∈ V , that is G is a yes-instance of Balanced Satisfactory Partition.
Balanced Satisfactory Partition has already been proved NP-complete in [4], even if both parts are required to be connected.Moreover, the reduction used in [4] does not construct a graph with vertices of degree n − 1.
Thus we obtain a similar result as in [10] (the authors have mentioned in the proof that used technique works also in a connected case).

Theorem 9 Connected Balanced 2-Community is NP-complete.
Finally, it is interesting to notice that there exist graphs in which every 2-community structure is balanced (see Fig. 4).

Conclusion and Open Problems
An interesting open question is to determine if a graph of size at least 4 (except stars) has always a 2-community structure, even a connected one.In this paper we prove that the statement is true for trees, graphs of maximum degree 3, minimum degree |V | − 3 and some other graph classes.Furthermore, such a structure can be found in polynomial time.The question remains open even for a weak 2-community structure where the partial positive results are only known for the same graph classes.
In case of Balanced 2-Community the situation is different.We show that any graph of maximum degree 3 has a balanced weak 2-community structure, while we present a graph without a balanced 2-community structure within the same class.Computationally speaking, finding a balanced weak 2-community structure can be done in polynomial time in graphs of maximum degree 3 while the Balanced 2-Community problem is NP-complete in general graphs just as its weak version.The results are similar for connected communities.
To get better understanding of community structures, there are some interesting problems left open, as to extend 2-community results to other graph classes, to characterise graph classes where the existential/complexity results for 2-community/weak 2-community problems and their connected versions are different or to generalise the results to k-communities for a fixed k, k ≥ 3.
Open Access This article is distributed under the terms of the Creative Commons Attribution 4.0 International License (http://creativecommons.org/licenses/by/4.0/),which permits unrestricted use, distribution, and reproduction in any medium, provided you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons license, and indicate if changes were made.

3 ( 3 + 1 Lemma 4
The vertices of degree 2 from the smaller part and all the vertices of degree 3 have at most one out-neighbour.(ii) The vertices of degree 2 and 3 have at most one out-neighbour and the partition is balanced.(iii) The vertices of degree 2 from the smaller part have at most one out-neighbour, the vertices of degree 3 in C i , for some i ∈ {1, 2}, have at most two out-neighbours and |C i | = n−1 or also |C i | = n−1 if n ≡ 1 mod 3) and the vertices of degree 3 in C 3−i have at most one out-neighbour.Proof In each case (i), (ii), or (iii), all the vertices of the graph G satisfy the condition (1) due to Lemmas 1 and 2. Hence, {C 1 , C 2 } is a 2-community structure on G. Every connected graph of maximum degree 3 on n vertices, n ≥ 4, (except a star) has a connected partition {C 1 , C 2 } such that n−1

Theorem 2
2 and the algorithm clearly runs in a polynomial time.Every connected graph of maximum degree 3 with at least 4 vertices (except a star) has a connected 2-community structure which can be found in polynomial time.

Stage 1 (
Category (A) vertices) In this stage we handle vertices in C 2 of degree 3 with two out-neighbours by transferring them into C 1 , keeping the size of C 1 smaller than n − n−1 3 and ensuring connectivity of the partition {C 1 , C 2 }.While |C 1 | < n − n−1 3 and there is a vertex u ∈ C 2 with two out-neighbours, update C 1 := C 1 ∪ {u}, C 2 := C 2 \ {u}.Notice that each iteration of Stage 1 decreases the size of the cut by at least one.The Improvement Procedure: Stage 2 (Category (A) vertices) Similarly to Stage 1, in Stage 2 we handle vertices in C 1 of degree 3 with two out-neighbours by transferring them into C 2 , keeping the size of C 2 smaller than n − n−1 3 and ensuring connectivity of the partition {C 1 , C 2 }.While |C 2 | < n − n−1

Theorem 5
such two vertices must have a common neighbour in B 1 .If B 1 = ∅, then either |O 1,1 | ≥ 3 or p ≥ 2 (due to assumptions on G), and such two vertices have a common neighbour either in O 1,1 or O j,1 , j = i.Hence, G[C 1 ] is also connected.Let G = (V, E) be a graph with minimum degree (c−1).|V| c where c is the size of an inclusion-wise maximal clique in G, i.e. such a clique is not a subgraph of another clique.Then, G has a connected 2-community structure which can be found in polynomial time.Proof If c ≥ |V | − 1, then for any vertex u ∈ V , d(u) ≥ (|V |−2).|V| |V |−1 ≥ |V | − 3 and the rest follows from Theorem 4.

1 . 1 |C 1 |− 1 2|C 1 |
which it can be easily shown that n 2 − 1 and n − 1 do not have common divisors.This implies that d(v) is a multiple of n − 1.Thus, d(v) = n − 1.Note Let {C 1 , C 2 } be a balanced partition of G and v ∈ C 1 be a vertex of degree n − 1.Since v has n 2 − 1 neighbours in its own part and n 2 in other part, v does not satisfy the condition of Balanced Satisfactory Partition.However, v satisfies the Balanced 2-Community condition since d in (v) |C 1 |−1 = Proposition For any graph with n vertices and maximum degree (n − 2) the problems Balanced Satisfactory Partition and Balanced 2-Community are equivalent.Proof Suppose that G = (V, E) is a yes-instance of Balanced Satisfactory Partition.Hence there exists a balanced partition{C 1 , C 2 } of V such that any vertex v ∈ V satisfies the condition d in (v) ≥ 1 2 d(v), which implies that d in (v) ≥ −1 d(v) = |C 1 |−1 n−1 d(v).Thus, G is a yes-instance of Balanced 2-Community.Suppose now that G is a yes-instance of Balanced 2-Community.Hence there exists a balanced partition{C 1 , C 2 } of V such that any vertex v ∈ V satisfies the condition d in (v) ≥ |C 1 |−1 |C 2 | d out (v) that is equivalent to d in (v) ≥ |C 1 |−1 n−1 d(v)using Lemma 6.According to Lemma 7, there is no vertex v such that d in (v) = |C 1 |−1

Fig. 4
Fig. 4 An example of a graph in which all 2-community structures are balanced 2. The algorithm starts with the initial set C 1 and repeats the Update Procedure until |C 1 | ≥ n−1 3 .In each run of the procedure only one of the options 1 or 2 is executed.The Update procedure: Let w be a vertex in C 2 which has a neighbour in C 1 (such a vertex must exist since G is connected).Option 1 If the subgraph induced by C 2 \ {w} is connected, put