有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

如果我有节点总数和节点之间的距离,如何创建路径?

我想生成一个图表。我总共有3个输入。节点总数和节点之间的距离

比如

Total no of nodes J = 6, 
no of path can be created from them R = 8
input3 = {1#2#8, 1#4#7, 1#5#12, 2#3#4, 2#4#2, 3#6#6, 4#6#8, 5#6#10}.

这是我掌握的信息。第一个数字表示起始节点,第二个数字表示结束节点,第三个数字表示它们之间的距离,即第一个和第二个节点之间的距离为8,第一个和第四个节点之间的距离为7,类似于此

现在我想从中创建路径。我需要这样的输出:

first path can be 1->2->3-> 6 and total cost for that is 18
second path can be 1->2->4->6 and total cost for that is 18
third path can be 1->4->6 and total cost for that is 15
fourth path can be 1->5->6 and total cost for that is 22

我如何用Java实现这种类型的程序


共 (0) 个答案