简体   繁体   English

Java比较图算法

[英]Java to compare graph algorithms

Is Java suitable for a project that will compare performances of Dijkstra and Bellman-Ford algorithms on given graphs? Java是否适合在给定图形上比较Dijkstra和Bellman-Ford算法性能的项目? Or do I have to use C? 或者我必须使用C?

语言开销是相同的,因此您可以使用任何语言来比较两种算法。

You can use any of the two languages as long as you are consistent and use the same language to implement both algorithms. 只要您保持一致并使用相同的语言来实现这两种算法,就可以使用这两种语言中的任何一种。

For example, writing Dijkstra in C and comparing it to Bellman-Ford written in Java is inaccurate. 例如,在C中编写Dijkstra并将其与用Java编写的Bellman-Ford进行比较是不准确的。

I think you should certainly be able to use Java for such a comparison. 我认为你当然应该能够使用Java进行这样的比较。 Although it might be harder to interpret your results. 虽然可能更难以解释您的结果。 For example, it might not be the best idea to write code that uses objects and garbage collection excessively since you would find it hard to isolate these effects from the raw running time. 例如,编写过度使用对象和垃圾收集的代码可能不是最好的想法,因为您会发现很难将这些效果与原始运行时间隔离开来。 The startup overhead will be similar, but within the algorithms, you could end up "using more Java" in one than in the other (probably in Dijkstra's algorithm with the tree) and hence slowing it down. 启动开销将类似,但在算法中,您可能最终“使用更多Java”而不是另一个(可能在Dijkstra的算法中使用树),从而减慢它的速度。

A good "test of the test" is to compare the two algorithms in several implementations in different languages. 一个好的“测试测试”是在不同语言的几种实现中比较两种算法。 If the comparison is consistent across implementations, then that is good evidence that the results were not due to an accident of the language or execution environment. 如果比较在各个实现中是一致的,则可以很好地证明结果不是由于语言或执行环境的意外。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM