def add_connection(self, node_id, distance, road_type):
"""添加与其他节点的连接"""
self.connections.append({
'node_id': node_id,
'distance': distance, # 距离 (km)
'road_type': road_type # 道路类型:'highway', 'city', 'rural'
})
def get_position(self):
"""获取节点位置"""
return (self.lat, self.lng)
def add_connection(self, node_id, distance, road_type):
"""添加与其他节点的连接"""
self.connections.append({
'node_id': node_id,
'distance': distance, # 距离 (km)
'road_type': road_type # 道路类型:'highway', 'city', 'rural'
})
def get_position(self):
"""获取节点位置"""
return (self.lat, self.lng)def add_connection(self, node_id, distance, road_type):
"""添加与其他节点的连接"""
self.connections.append({
'node_id': node_id,
'distance': distance, # 距离 (km)
'road_type': road_type # 道路类型:'highway', 'city', 'rural'
})
def get_position(self):
"""获取节点位置"""
return (self.lat, self.lng)def add_connection(self, node_id, distance, road_type):
"""添加与其他节点的连接"""
self.connections.append({
'node_id': node_id,
'distance': distance, # 距离 (km)
'road_type': road_type # 道路类型:'highway', 'city', 'rural'
})
def get_position(self):
"""获取节点位置"""
return (self.lat, self.lng)