简体   繁体   中英

Java to compare graph algorithms

Is Java suitable for a project that will compare performances of Dijkstra and Bellman-Ford algorithms on given graphs? Or do I have to use 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.

I think you should certainly be able to use Java for such a comparison. 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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