File size: 791 Bytes
0857e86
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# 准备图数据
import osmnx as ox


def get_graph():
    G = ox.load_graphml('dataset/G_new.graphml')
    # 补充节点和边的lon,lat特征
    # nodes, edges = assign_edge_attr(G)
    # 读取目前的路网
    # import networkx as nx
    # G_new = nx.Graph()
    # import tqdm
    # print("开始读入节点")
    # pos_location = {}
    # for node_id, row in nodes.iterrows():
    #     G_new.add_node(node_id, y=row['y'], x=row['x'])  # 节点id,节点经纬度
    #     pos_location[node_id] = (row['y'], row['x'])
    # e_cnt = 0
    # print("开始读入边")
    # for node_id_1, node_id_2, _ in G.edges:
    #     G_new.add_edge(node_id_1, node_id_2)  # 边:节点id
    #
    #
    # # 去掉自环
    # G_new.remove_edges_from(nx.selfloop_edges(G_new))
    return G