<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def execute(self):
 """ Execute Demon algorithm """


        for n in self.g.nodes():
            self.g.node[n]['communities'] = [n]

        all_communities = {}

        for ego in tqdm.tqdm(nx.nodes(self.g), ncols=35, bar_format='Exec: {l_bar}{bar}'):

            ego_minus_ego = nx.ego_graph(self.g, ego, 1, False)
            community_to_nodes = self.__overlapping_label_propagation(ego_minus_ego, ego)

            # merging phase
            for c in community_to_nodes.keys():
                if len(community_to_nodes[c]) > self.min_community_size:
                    actual_community = community_to_nodes[c]
                    all_communities = self.__merge_communities(all_communities, actual_community)

        # write output on file
        if self.file_output:
            with open(self.file_output, "w") as out_file_com:
                for idc, c in enumerate(all_communities.keys()):
                    out_file_com.write("%d\t%s\n" % (idc, str(sorted(c))))

        return list(all_communities.keys())