def main(self, dir):
        '''
        :return:
        '''
        # filename= 'treenetwork3000.txt' #半径为40
        #对于树图,以及普通图。参数可能设置不一样,h变换不一样。需要手动调整。
        # filename = 'CA-GrQc.txt'
        self.radius = 6

        pre = '../data/'
        last = '.txt'
        # filename = ''
        self.initG = commons.get_networkByFile(fileName=pre + dir +
                                               last)  # 获取图,
        max_sub_graph = commons.judge_data(self.initG)
        source_list = commons.product_sourceList(max_sub_graph,
                                                 self.fix_number_source)
        self.true_Source_list = source_list
        self.infectG = commons.propagation1(self.initG,
                                            self.true_Source_list)  # 开始传染
        self.revsitionAlgorithm_pre(self.infectG)  # 找到反转算法后的生成答案点
        self.cal_BFS_monte_Carlo()  # 找到最好的覆盖率结果。
        self.cal_reverse_algorithm(self.infectG)  # 找到反转算法后的生成答案点
        self.distance_error = commons.cal_distance(self.infectG,
                                                   self.true_Source_list,
                                                   self.findSource_list)
Example #2
0
    def main(self, dir):
        '''
        :return:
        '''
        # filename= '../data/treenetwork3000.txt' #半径为40
        # 对于树图,以及普通图。参数可能设置不一样,h变换不一样。需要手动调整。

        # dir = './data_center/treenetwork3000.txt'
        pre = '../data/'
        last = '.txt'
        # filename = ''
        # self.get_networkByFile(fileName=pre + dir + last)  # 获取图,
        self.radius = 6  #CA-GRQC半径。
        # self.get_networkByFile(fileName=filename)  # 获取图,

        self.initG = commons.get_networkByFile(fileName=pre + dir +
                                               last)  # 获取图,
        max_sub_graph = commons.judge_data(self.initG)
        source_list = commons.product_sourceList(max_sub_graph,
                                                 self.fix_number_source)
        self.true_Source_list = source_list
        self.infectG = commons.propagation1(self.initG,
                                            self.true_Source_list)  # 开始传染

        # self.revsitionAlgorithm_pre(self.infectG)  # 找到反转算法后的生成答案点
        self.cal_BFS_monte_Carlo('./data_center/' + dir +
                                 '.txt')  # 找到结果后构建BFS树,进行采样判断覆盖率。
        self.cal_reverse_algorithm(self.infectG)  # 找到反转算法后的生成答案点
        self.distance_error = commons.cal_distance(self.infectG,
                                                   self.true_Source_list,
                                                   self.findSource_list)
Example #3
0
    def main(self, filename):
        # #拿到图
        # subGraph=self.get_Graph('../Propagation_subgraph/many_methods/result/chouqu.txt')

        # initG = commons.get_networkByFile('../../../data/CA-GrQc.txt')
        # initG = commons.get_networkByFile('../../../data/3regular_tree1000.txt')
        # initG = commons.get_networkByFile('../../data/4_regular_graph_3000_data.txt')

        initG = commons.get_networkByFile(filename)
        # initG = commons.get_networkByFile('../../../data/4_regular_graph_3000_data.txt')

        # initG = commons.get_networkByFile('../../../data/email-Eu-core.txt')

        max_sub_graph = commons.judge_data(initG)
        # source_list = product_sourceList(max_sub_graph, 2)
        source_list = commons.product_sourceList(max_sub_graph, 2)
        # print('两个节点的距离', nx.shortest_path_length(max_sub_graph, source=source_list[0], target=source_list[1]))
        infectG = commons.propagation1(max_sub_graph, source_list)

        # subinfectG = commons.get_subGraph_true(infectG)  # 只取感染点,为2表示,真实的感染图。
        single_Source_detection_object = single_Source_detection.Single_source(
        )
        '''
        底下将是所有的步骤组合操作。目前是2源的。
        1  抽取子图操作
        2  分区
        3 分别多源定位
        '''

        # 1  抽取子图操作,共有3种抽取子图操作。我们选择那3种呢?
        subinfectG = commons.get_subGraph_true(infectG)  # 只取感染点,为2表示,真实的感染图。
        '''''' '# 2 分区,分区的太多了,我们看看那种好。' ''

        result = self.findmultiplesource(infectG, subinfectG, sourceNumber=2)

        result_source_list = []
        for community in result:
            subsubinfectG = nx.Graph()
            for edge in list(subinfectG.edges()):
                if edge[0] in community and (edge[1] in community):
                    subsubinfectG.add_edge(edge[0], edge[1])
            # 看下图连通吗。
            maxsubsubinfectG = self.judge_data(subsubinfectG)
            # 开始单源定位了。
            '''jar center'''
            source_node = single_Source_detection_object.revsitionAlgorithm_singlueSource(
                maxsubsubinfectG)
            # source_node = single_Source_detection_object.single_source_bydistance_coverage(infectG, maxsubsubinfectG)
            result_source_list.append(source_node[0])

        distance = commons.cal_distance(max_sub_graph, source_list,
                                        result_source_list)

        return distance
Example #4
0
 def main(self,dir):
     '''
     走来不要那么难,先搞定树吧。才能继续搞定图。
     :return:
     '''
     pre = '../data/'
     last = '.txt'
     # filename = ''
     self.initG = commons.get_networkByFile(fileName=pre+dir+last)  # 获取图,
     max_sub_graph = commons.judge_data( self.initG)
     source_list = commons.product_sourceList(max_sub_graph, self.fix_number_source)
     self.true_Source_list = source_list
     self.infectG = commons.propagation1(max_sub_graph,self.true_Source_list)  # 开始传染
     self.cal_ecctity()      #找到最好的覆盖率结果。
     self.cal_reverse_algorithm(self.infectG)  # 找到反转算法后的生成答案点
     self.distance_error = commons.cal_distance(self.infectG, self.true_Source_list, self.findSource_list)
Example #5
0
    def main(self, filename):
        # #拿到图
        # subGraph=self.get_Graph('../Propagation_subgraph/many_methods/result/chouqu.txt')

        # initG = commons.get_networkByFile('../../../data/CA-GrQc.txt')
        # initG = commons.get_networkByFile('../../../data/3regular_tree1000.txt')
        # initG = commons.get_networkByFile('../../data/4_regular_graph_3000_data.txt')

        initG = commons.get_networkByFile(filename)
        # initG = commons.get_networkByFile('../../../data/4_regular_graph_3000_data.txt')

        # initG = commons.get_networkByFile('../../../data/email-Eu-core.txt')

        max_sub_graph = commons.judge_data(initG)
        # source_list = product_sourceList(max_sub_graph, 2)
        source_list = commons.product_sourceList(max_sub_graph, 2)
        # print('两个节点的距离', nx.shortest_path_length(max_sub_graph, source=source_list[0], target=source_list[1]))
        infectG = commons.propagation1(max_sub_graph, source_list)

        subinfectG = commons.get_subGraph_true(infectG)  # 只取感染点,为2表示,真实的感染图。
        '''
        底下将是所有的步骤组合操作。目前是2源的。
        1  抽取子图操作
        2  分区
        3 分别多源定位
        '''

        # 1  抽取子图操作,共有3种抽取子图操作。我们选择那3种呢?
        subinfectG = commons.get_subGraph_true(infectG)  # 只取感染点,为2表示,真实的感染图。
        '''''' '# 2 分区,分区的太多了,我们看看那种好。' ''

        result = self.findmultiplesource(infectG, subinfectG, sourceNumber=2)

        distance = commons.cal_distance(max_sub_graph, source_list, result)

        return distance
Example #6
0
    def main(self, filename):
        # #拿到图
        # subGraph=self.get_Graph('../Propagation_subgraph/many_methods/result/chouqu.txt')

        # initG = commons.get_networkByFile('../../../data/CA-GrQc.txt')
        # initG = commons.get_networkByFile('../../../data/3regular_tree1000.txt')
        initG = commons.get_networkByFile(filename)

        # initG = commons.get_networkByFile('../../../data/CA-GrQc.txt')
        # initG = commons.get_networkByFile('../../../data/4_regular_graph_3000_data.txt')

        # initG = commons.get_networkByFile('../../../data/email-Eu-core.txt')

        max_sub_graph = commons.judge_data(initG)
        # source_list = product_sourceList(max_sub_graph, 2)
        source_list = commons.product_sourceList(max_sub_graph, 2)
        # print('两个节点的距离', nx.shortest_path_length(max_sub_graph, source=source_list[0], target=source_list[1]))
        infectG = commons.propagation1(max_sub_graph, source_list)

        subinfectG = commons.get_subGraph_true(infectG)  # 只取感染点,为2表示,真实的感染图。
        self.judge_data(subinfectG)

        # single_source = commons.revsitionAlgorithm_singlueSource(subinfectG)
        distance_iter = nx.shortest_path_length(subinfectG)
        everynode_distance = []
        for node, node_distance in distance_iter:
            # print(node_distance)
            sort_list = sorted(node_distance.items(),
                               key=lambda x: x[1],
                               reverse=True)
            # print('sort_list',sort_list)
            everynode_distance.append([node, sort_list[0][0], sort_list[0][1]])
        # print('everynode_idstance',everynode_distance)
        sort_every_distance = sorted(everynode_distance,
                                     key=lambda x: x[2],
                                     reverse=True)
        print('sort_every_distance', sort_every_distance)

        #从两个最远的点进行BFS直到找到单源的位置。

        # print(nx.shortest_path_length(infectG,source=single_source[0],target=sort_every_distance[0][0]))
        # print(nx.shortest_path_length(infectG, source=single_source[0], target=sort_every_distance[0][1]))
        #
        # print(nx.shortest_path_length(infectG, source=single_source[0], target=sort_every_distance[1][0]))
        # print(nx.shortest_path_length(infectG, source=single_source[0], target=sort_every_distance[1][1]))
        #
        # print(nx.shortest_path_length(infectG, source=single_source[0], target=sort_every_distance[2][0]))
        # print(nx.shortest_path_length(infectG, source=single_source[0], target=sort_every_distance[2][1]))

        # #根据最远得点,把我们的那个啥,分区,然后利用分区点进行单源定位。。
        node_twolist = [[], []]
        lengthA_dict = nx.single_source_bellman_ford_path_length(
            subinfectG, sort_every_distance[0][0], weight='weight')
        lengthB_dict = nx.single_source_bellman_ford_path_length(
            subinfectG, sort_every_distance[0][1], weight='weight')
        for node in list(subinfectG.nodes):
            if lengthA_dict[node] > lengthB_dict[node]:  # 这个点离b近一些。
                node_twolist[1].append(node)
            elif lengthA_dict[node] < lengthB_dict[node]:
                node_twolist[0].append(node)
            # else:
            #     node_twolist[0].append(node)
            #     node_twolist[1].append(node)
        print('len(node_twolist[0]', len(node_twolist[0]))
        print('len(node_twolist[1]', len(node_twolist[1]))
        # 边界点。
        bound_list = []
        for node_temp in list(infectG.nodes()):
            # print(node_temp)
            if infectG.node[node_temp]['SI'] == 2:
                neighbors_list = list(nx.neighbors(infectG, node_temp))
                neighbors_infect_list = [
                    x for x in neighbors_list if infectG.node[x]['SI'] == 2
                ]
                if len(neighbors_list) != 1 and len(
                        neighbors_infect_list) == 1:
                    # if  len(neighbors_infect_list) == 1:
                    bound_list.append(node_temp)

        print('boundelist', len(bound_list))

        print('len(kjlk)',
              len([x for x in bound_list if x in list(subinfectG.nodes())]))
        left = [x for x in bound_list if x in node_twolist[0]]
        right = [x for x in bound_list if x in node_twolist[1]]

        print('left', left)
        print('right', right)

        left_source = commons.revsitionAlgorithm_singlueSource_receive(
            subinfectG, left)
        right_source = commons.revsitionAlgorithm_singlueSource_receive(
            subinfectG, right)
        if set(left) < set(list(subinfectG.nodes())):
            print('left在感染点里面啊')
        if set(right) < set(list(subinfectG.nodes())):
            print('left在感染点里面啊')
        distance = commons.cal_distance(infectG,
                                        [left_source[0], right_source[0]],
                                        source_list)

        return distance
Example #7
0
    def main(self, filename):
        # #拿到图
        # subGraph=self.get_Graph('../Propagation_subgraph/many_methods/result/chouqu.txt')

        # initG = commons.get_networkByFile('../../../data/CA-GrQc.txt')
        # initG = commons.get_networkByFile('../../../data/3regular_tree1000.txt')
        initG = commons.get_networkByFile(filename)

        # initG = commons.get_networkByFile('../../../data/CA-GrQc.txt')
        # initG = commons.get_networkByFile('../../../data/4_regular_graph_3000_data.txt')

        # initG = commons.get_networkByFile('../../../data/email-Eu-core.txt')

        max_sub_graph = commons.judge_data(initG)
        # source_list = product_sourceList(max_sub_graph, 2)
        source_list = commons.product_sourceList(max_sub_graph, 2)
        # print('两个节点的距离', nx.shortest_path_length(max_sub_graph, source=source_list[0], target=source_list[1]))
        infectG = commons.propagation1(max_sub_graph, source_list)

        subinfectG = commons.get_subGraph_true(infectG)  # 只取感染点,为2表示,真实的感染图。
        '''
        思路:
        1  借助概率p= 0,5以及不同的时间t生成大量的集合。假设知道时间吧。
        2 然后用这些集合去覆盖感染区域,尽可能让blue中点多,而红色区域少。
            这种方法还可以用来确定种子节点的。
            
        
        '''

        # 1  抽取子图操作,共有3种抽取子图操作。我们选择那3种呢?
        subinfectG = commons.get_subGraph_true(infectG)  # 只取感染点,为2表示,真实的感染图。
        '''''' '# 2 分区,分区的太多了,我们看看那种好。' ''

        self.product_many_region(0.5, 6, infectG, subinfectG, source_list)

        partion_graph_object = Partion_graph.Partion_graph()
        result = partion_graph_object.other_k_center(infectG,
                                                     subinfectG,
                                                     source_list,
                                                     source_number=2)

        single_Source_detection_object = single_Source_detection.Single_source(
        )
        print('result', result)
        # 对每一个感染的点建图,用真实的建成一个传播子图
        result_source_list = []
        '''

            3  针对2传回来的多个区域,开始定位源点。
         '''
        for community in result:
            subsubinfectG = nx.Graph()
            for edge in list(subinfectG.edges()):
                if edge[0] in community and (edge[1] in community):
                    subsubinfectG.add_edge(edge[0], edge[1])
            # 看下图连通吗。
            maxsubsubinfectG = self.judge_data(subsubinfectG)
            # 开始单源定位了。
            '''jar center'''
            # source_node = single_Source_detection_object.revsitionAlgorithm_singlueSource(maxsubsubinfectG)
            source_node = single_Source_detection_object.single_source_bydistance_coverage(
                infectG, maxsubsubinfectG)
            #
            # source_node = single_Source_detection_object.single_source_bydistance(maxsubsubinfectG)

            result_source_list.append(source_node[0])

        distance = commons.cal_distance(max_sub_graph, source_list,
                                        result_source_list)

        return distance
    def main(self):
        # #拿到图
        # subGraph=self.get_Graph('../Propagation_subgraph/many_methods/result/chouqu.txt')

        # initG = commons.get_networkByFile('../data/CA-GrQc.txt')
        # initG = commons.get_networkByFile('../data/3regular_tree1000.txt')
        initG = commons.get_networkByFile(
            '../../data/4_regular_graph_3000_data.txt')

        # initG = commons.get_networkByFile('../../../data/CA-GrQc.txt')
        # initG = commons.get_networkByFile('../../../data/4_regular_graph_3000_data.txt')

        # initG = commons.get_networkByFile('../../../data/email-Eu-core.txt')

        max_sub_graph = commons.judge_data(initG)
        # source_list = product_sourceList(max_sub_graph, 2)
        source_list = commons.product_sourceList(max_sub_graph, 2)
        # print('两个节点的距离', nx.shortest_path_length(max_sub_graph, source=source_list[0], target=source_list[1]))
        infectG = commons.propagation1(max_sub_graph, source_list)

        subinfectG = commons.get_subGraph_true(infectG)  # 只取感染点,为2表示,真实的感染图。
        '''
        底下将是所有的步骤组合操作。目前是2源的。
        1  抽取子图操作
        2  分区
        3 分别多源定位
        '''

        # 1  抽取子图操作,共有3种抽取子图操作。我们选择那3种呢?
        subinfectG = commons.get_subGraph_true(infectG)  # 只取感染点,为2表示,真实的感染图。
        '''''' '# 2 分区,分区的太多了,我们看看那种好。' ''
        '''2.1  Different'''

        result = self.Parttion_Different_Time(infectG, sourceNumber=2)
        print('result', len(result))
        single_Source_detection_object = single_Source_detection.Single_source(
        )
        print('result', result)
        # 对每一个感染的点建图,用真实的建成一个传播子图
        result_source_list = []
        '''

            3  针对2传回来的多个区域,开始定位源点。
         '''
        for community_node, community in result:
            subsubinfectG = nx.Graph()
            for edge in list(subinfectG.edges()):
                if edge[0] in community and (edge[1] in community):
                    subsubinfectG.add_edge(edge[0], edge[1])
            # 看下图连通吗。
            maxsubsubinfectG = self.judge_data(subsubinfectG)
            # 开始单源定位了。

            source_node = single_Source_detection_object.revsitionAlgorithm_singlueSource(
                maxsubsubinfectG)
            result_source_list.append(source_node[0])

        distance = commons.cal_distance(max_sub_graph, source_list,
                                        result_source_list)

        return distance
Example #9
0
    def randmo_BFS(self, infectG, subinfectG, true_list):

        # single_source = commons.revsitionAlgorithm_singlueSource(subinfectG)
        distance_iter = nx.shortest_path_length(subinfectG)
        everynode_distance = []
        for node, node_distance in distance_iter:
            # print(node_distance)
            sort_list = sorted(node_distance.items(),
                               key=lambda x: x[1],
                               reverse=True)
            # print('sort_list',sort_list)
            everynode_distance.append([node, sort_list[0][0], sort_list[0][1]])
        # print('everynode_idstance',everynode_distance)
        sort_every_distance = sorted(everynode_distance,
                                     key=lambda x: x[2],
                                     reverse=True)
        print('sort_every_distance', sort_every_distance)

        #从两个最远的点进行BFS直到找到单源的位置。

        # print(nx.shortest_path_length(infectG,source=single_source[0],target=sort_every_distance[0][0]))
        # print(nx.shortest_path_length(infectG, source=single_source[0], target=sort_every_distance[0][1]))
        #
        # print(nx.shortest_path_length(infectG, source=single_source[0], target=sort_every_distance[1][0]))
        # print(nx.shortest_path_length(infectG, source=single_source[0], target=sort_every_distance[1][1]))
        #
        # print(nx.shortest_path_length(infectG, source=single_source[0], target=sort_every_distance[2][0]))
        # print(nx.shortest_path_length(infectG, source=single_source[0], target=sort_every_distance[2][1]))

        # #根据最远得点,把我们的那个啥,分区,然后利用分区点进行单源定位。。
        node_twolist = [[], []]
        lengthA_dict = nx.single_source_bellman_ford_path_length(
            subinfectG, sort_every_distance[0][0], weight='weight')
        lengthB_dict = nx.single_source_bellman_ford_path_length(
            subinfectG, sort_every_distance[0][1], weight='weight')
        for node in list(subinfectG.nodes):
            if lengthA_dict[node] > lengthB_dict[node]:  # 这个点离b近一些。
                node_twolist[1].append(node)
            elif lengthA_dict[node] < lengthB_dict[node]:
                node_twolist[0].append(node)
            # else:
            #     node_twolist[0].append(node)
            #     node_twolist[1].append(node)
        print('len(node_twolist[0]', len(node_twolist[0]))
        print('len(node_twolist[1]', len(node_twolist[1]))
        # 边界点。
        bound_list = []
        for node_temp in list(infectG.nodes()):
            # print(node_temp)
            if infectG.node[node_temp]['SI'] == 2:
                neighbors_list = list(nx.neighbors(infectG, node_temp))
                neighbors_infect_list = [
                    x for x in neighbors_list if infectG.node[x]['SI'] == 2
                ]
                if len(neighbors_list) != 1 and len(
                        neighbors_infect_list) == 1:
                    # if  len(neighbors_infect_list) == 1:
                    bound_list.append(node_temp)

        print('boundelist', len(bound_list))

        print('len(kjlk)',
              len([x for x in bound_list if x in list(subinfectG.nodes())]))
        left = [x for x in bound_list if x in node_twolist[0]]
        right = [x for x in bound_list if x in node_twolist[1]]

        print('left', left)
        print('right', right)

        left_source = commons.revsitionAlgorithm_singlueSource_receive(
            subinfectG, left)
        right_source = commons.revsitionAlgorithm_singlueSource_receive(
            subinfectG, right)
        if set(left) < set(list(subinfectG.nodes())):
            print('left在感染点里面啊')
        if set(right) < set(list(subinfectG.nodes())):
            print('left在感染点里面啊')
        print(
            'distance',
            commons.cal_distance(infectG, [left_source[0], right_source[0]],
                                 true_list))

        return node_twolist

        pass
    def main(self, filename):
        # #拿到图
        # subGraph=self.get_Graph('../Propagation_subgraph/many_methods/result/chouqu.txt')

        # initG = commons.get_networkByFile('../../../data/CA-GrQc.txt')
        # initG = commons.get_networkByFile('../../../data/3regular_tree1000.txt')
        initG = commons.get_networkByFile(filename)

        # initG = commons.get_networkByFile('../../../data/CA-GrQc.txt')
        # initG = commons.get_networkByFile('../../../data/4_regular_graph_3000_data.txt')

        # initG = commons.get_networkByFile('../../../data/email-Eu-core.txt')

        max_sub_graph = commons.judge_data(initG)
        # source_list = product_sourceList(max_sub_graph, 2)
        source_list = commons.product_sourceList(max_sub_graph, 2)
        # print('两个节点的距离', nx.shortest_path_length(max_sub_graph, source=source_list[0], target=source_list[1]))
        infectG = commons.propagation1(max_sub_graph, source_list)

        subinfectG = commons.get_subGraph_true(infectG)  # 只取感染点,为2表示,真实的感染图。
        self.judge_data(subinfectG)
        '''
        思路:
        1  借助概率p= 0,5以及不同的时间t生成大量的集合。假设知道时间吧。
        2 然后用这些集合去覆盖感染区域,尽可能让blue中点多,而红色区域少。
            这种方法还可以用来确定种子节点的。

        '''

        # 1  抽取子图操作,共有3种抽取子图操作。我们选择那3种呢?
        subinfectG = commons.get_subGraph_true(infectG)  # 只取感染点,为2表示,真实的感染图。
        '''''' '# 2 分区,分区的太多了,我们看看那种好。' ''
        partion_graph_object = Partion_graph.Partion_graph()

        #开始分区,怎么分呢?
        #根据边界节点来。两部分的边界节点,能够找到两个点使得他们到边界点的距离最短?

        #
        # result = partion_graph_object.other_k_center(infectG, subinfectG, source_list, source_number=2)
        #

        # single_source = commons.revsitionAlgorithm_singlueSource(subinfectG)
        distance_iter = nx.shortest_path_length(subinfectG)
        everynode_distance = []
        for node, node_distance in distance_iter:
            # print(node_distance)
            sort_list = sorted(node_distance.items(),
                               key=lambda x: x[1],
                               reverse=True)
            # print('sort_list',sort_list)
            everynode_distance.append([node, sort_list[0][0], sort_list[0][1]])
        # print('everynode_idstance',everynode_distance)
        sort_every_distance = sorted(everynode_distance,
                                     key=lambda x: x[2],
                                     reverse=True)
        print('sort_every_distance', sort_every_distance)

        #从两个最远的点进行BFS直到找到单源的位置。

        # print(nx.shortest_path_length(infectG,source=single_source[0],target=sort_every_distance[0][0]))
        # print(nx.shortest_path_length(infectG, source=single_source[0], target=sort_every_distance[0][1]))
        #
        # print(nx.shortest_path_length(infectG, source=single_source[0], target=sort_every_distance[1][0]))
        # print(nx.shortest_path_length(infectG, source=single_source[0], target=sort_every_distance[1][1]))
        #
        # print(nx.shortest_path_length(infectG, source=single_source[0], target=sort_every_distance[2][0]))
        # print(nx.shortest_path_length(infectG, source=single_source[0], target=sort_every_distance[2][1]))

        # #根据最远得点,把我们的那个啥,分区,然后利用分区点进行单源定位。。
        node_twolist = [[], []]
        lengthA_dict = nx.single_source_bellman_ford_path_length(
            subinfectG, sort_every_distance[0][0], weight='weight')
        lengthB_dict = nx.single_source_bellman_ford_path_length(
            subinfectG, sort_every_distance[0][1], weight='weight')
        for node in list(subinfectG.nodes):
            if lengthA_dict[node] > lengthB_dict[node]:  # 这个点离b近一些。
                node_twolist[1].append(node)
            elif lengthA_dict[node] < lengthB_dict[node]:
                node_twolist[0].append(node)
            # else:
            #     node_twolist[0].append(node)
            #     node_twolist[1].append(node)
        print('len(node_twolist[0]', len(node_twolist[0]))
        print('len(node_twolist[1]', len(node_twolist[1]))
        # 边界点。
        bound_list = []
        for node_temp in list(infectG.nodes()):
            # print(node_temp)
            if infectG.node[node_temp]['SI'] == 2:
                neighbors_list = list(nx.neighbors(infectG, node_temp))
                neighbors_infect_list = [
                    x for x in neighbors_list if infectG.node[x]['SI'] == 2
                ]
                if len(neighbors_list) != 1 and len(
                        neighbors_infect_list) == 1:
                    # if  len(neighbors_infect_list) == 1:
                    bound_list.append(node_temp)

        print('boundelist', len(bound_list))

        print('len(kjlk)',
              len([x for x in bound_list if x in list(subinfectG.nodes())]))
        left = [x for x in bound_list if x in node_twolist[0]]
        right = [x for x in bound_list if x in node_twolist[1]]

        print('left', left)
        print('right', right)

        left_source = commons.revsitionAlgorithm_singlueSource_receive(
            subinfectG, left)
        right_source = commons.revsitionAlgorithm_singlueSource_receive(
            subinfectG, right)
        if set(left) < set(list(subinfectG.nodes())):
            print('left在感染点里面啊')
        if set(right) < set(list(subinfectG.nodes())):
            print('left在感染点里面啊')
        distance = commons.cal_distance(infectG,
                                        [left_source[0], right_source[0]],
                                        source_list)

        return distance