首先维护一张两点之间的表
tmp:

a b
1 2
insert into tmp
select * from tmp t
where not exists (
select 1 from tmp where t.b=#{a} and t.a=#{b}
)
and not exists (
select 1 from tmp where t.a=#{a} and t.b=#{b}
);
保证任意两点之间只会存在一条记录 互为相反的也存一条
然后
加上递归算法就能实现求任意两点之间最短的距离

相关文章:

  • 2021-09-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-30
  • 2022-12-23
  • 2022-12-23
  • 2021-11-24
猜你喜欢
  • 2021-07-15
  • 2022-12-23
  • 2021-06-06
  • 2022-12-23
  • 2022-01-14
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案