private boolean phaseOne(Graph<V, E> graph) {
		boolean gainOccurred = false;
		double maxDQ = 0;
		communities = new HashSet<>();

		m2 = 0;
		for (E e : graph.getEdges()) {
			m2 += edgesValues.get(e);
		}
		m2 *= 2;

		/*
		 * Setting every node in different group.
		 */
		for (V v : graph.getVertices()) {
			Set<V> group = new HashSet<>();
			group.add(v);
			communities.add(group);
		}

		for (V node : graph.getVertices()) {
			maxDQ = 0;
			Set<V> newGroup = null;
			// looking for best change
			double dQremoved = calcualteDeltaModularity(node, findVertexGroup(node), graph); // difference in modularity obtained by removing from current
																								// community
			for (Set<V> neighbourGroup : findNeighborGroups(node, graph)) {
				double dQ = calcualteDeltaModularity(node, neighbourGroup, graph) - dQremoved;
				if (dQ > maxDQ) {
					maxDQ = dQ;
					newGroup = neighbourGroup;
					gainOccurred = true;
				}
			}

			if (newGroup != null) {
				findVertexGroup(node).remove(node);
				newGroup.add(node);
			}
		}

		return gainOccurred;
	}