简体   繁体   English

滑动拼图的图形表示

[英]Graph representation of sliding puzzle

I need to represent a sliding puzzle that goes from 2x2 to 4x4 using graphs.我需要使用图形表示一个从2x24x4的滑动拼图。 I am aware that a state of the puzzle can represent a vertex and the other possibilities are connected with edges.我知道拼图的一种状态可以代表一个顶点,而其他可能性与边有关。 I am not sure how to begin and how to create the vertices and the connections with edges.我不确定如何开始以及如何创建顶点和与边的连接。 For example, a 3x3 puzzle has 9!例如,一个3x3 的拼图有 9 个! vertices, but how can I create that graph in java?顶点,但如何在 Java 中创建该图?

You can use JGraphT library.您可以使用JGraphT库。 Have a look at Graph interface implementations for the supported graphs.查看支持图形的 图形接口实现。

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

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