def compute_adjency(path, name):
    adjency = defaultdict(list)
    with open(path + name) as f:
        sections = list(per_section(f))
        for elt in sections[0]:
            adjency[int(elt.split(',')[0])].append(int(elt.split(',')[1]))
    return adjency
def graph_indicator(path, name):
    data_dict = defaultdict(list)
    with open(path + name) as f:
        sections = list(per_section(f))
        k = 1
        for elt in sections[0]:
            data_dict[int(elt)].append(k)
            k = k + 1
    return data_dict
def graph_label_list(path, name):
    graphs = []
    with open(path + name) as f:
        sections = list(per_section(f))
        k = 1
        for elt in sections[0]:
            graphs.append((k, int(elt)))
            k = k + 1
    return graphs
def node_labels_dic(path, name):
    node_dic = dict()
    with open(path + name) as f:
        sections = list(per_section(f))
        k = 1
        for elt in sections[0]:
            node_dic[k] = int(elt)
            k = k + 1
    return node_dic
示例#5
0
def node_attr_dic(path, name):
    node_dic = dict()
    with open(path + name) as f:
        sections = list(per_section(f))
        k = 1
        for elt in sections[0]:
            node_dic[k] = [float(x) for x in elt.split(',')]
            k = k + 1
    return node_dic
def node_attr_dic(path, name):
    node_dic = dict()
    with open(path + name) as f:
        sections = list(per_section(f))
        k = 1
        for elt in sections[0]:
            node_dic[k] = [round(float(x), 4) for x in elt.split(',')]
            if np.isnan(node_dic[k]).any():  # then there are None values
                node_dic[k] = [
                    0.00 if math.isnan(x) else x for x in node_dic[k]
                ]  # remove NaNs
            else:
                node_dic[k] = [x for x in node_dic[k]
                               ]  # x/max(node_dic[k])normalize
            node_dic[k] = [x for x in node_dic[k][:]]
            k = k + 1
    return node_dic