简体   繁体   English

Java中Graph的数据结构

[英]data structure for Graph in java

i am looking to implement a algorithm for the Travel Salesman Problem. 我正在寻找一种实现旅行推销员问题的算法。 I want to model the solution using the graph , in this a vertex will represent a city and edge will represent the cost from one city to another. 我想使用图形对解决方案进行建模 ,在此顶点将代表一个城市,而将代表从一个城市到另一个城市的成本。 At any point i have to compute cost from one city to another like (cityA, cityB)--->cost 在任何时候,我都必须计算从一个城市到另一个城市的成本,例如(cityA,cityB)---> cost

What data structure in java should i use for graph? 我应该使用Java中的哪种数据结构来显示图形?

And what kind of GUI tool or library can i use to represent a graph ? 我可以使用哪种GUI工具或库来表示图形?

如果您可以自由使用外部库,则JGraphT易于使用。

Why a graph, of course. 为什么要用图呢? Take a look at JUNG . 看看

depending on the size of your problem and your hardware, you might want to take a look at nosql graph databases like: http://neo4j.org/ 根据问题的大小和硬件的不同,您可能需要看一下nosql图形数据库,例如: http : //neo4j.org/

most of them are easy to handle and some (like neo4j) provide a graph visualization which is nice for debugging purpose. 它们中的大多数易于操作,并且某些(例如neo4j)提供了图形可视化,非常适合调试目的。

if you want to develop with as much performance as possible, you might have to create your own simple graph format. 如果要以尽可能高的性能进行开发,则可能必须创建自己的简单图形格式。 Most of the told ones are slow due to a lot of overhead (generics etc.) 由于大量的开销(泛型等),大多数告知的都是缓慢的

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

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