Graph algorithms play an important role in many computer science areas. In order to solve problems that can be modeled using graphs, it is necessary to use a data structure that can represent those graphs in an efficient manner. On top of this, an infrastructure should be build that will assist in implementing common algorithms or developing specialized ones. Here, a new Java library is introduced, called Graph4J, that uses a different approach when compared to existing, well-known Java libraries such as JGraphT, JUNG and Guava Graph. Instead of using object-oriented data structures for graph representation, a lower-level model based on arrays of primitive values is utilized, that drastically reduces the required memory and the running times of the algorithm implementations. The design of the library, the space complexity of the graph structures and the time complexity of the most common graph operations are presented in detail, along with an experimental study that evaluates its performance, when compared to the other libraries. Emphasis is given to infrastructure related aspects, that is graph creation, inspection, alteration and traversal. The improvements obtained for other implemented algorithms are also analyzed and it is shown that the proposed library significantly outperforms the existing ones.
翻译:图算法在计算机科学诸多领域中扮演着重要角色。为求解可通过图建模的问题,必须采用能够高效表示这些图的数据结构。在此基础上,应构建辅助实现常见算法或开发专用算法的底层基础设施。本文提出了一种名为Graph4J的新型Java库,其采用与现有主流Java库(如JGraphT、JUNG和Guava Graph)截然不同的技术路线。该库摒弃面向对象的图数据结构,转而采用基于原始值数组的低层级模型,从而显著降低内存需求并缩短算法实现运行时间。本文详细阐述了库的设计方案、图结构的空间复杂度及最常见图操作的时间复杂度,并通过实验研究将其性能与其他同类库进行对比评估。研究重点聚焦于基础设施相关方面(即图的创建、检查、修改与遍历),同时分析了其他已实现算法的性能提升。结果表明,所提出的库在性能上显著优于现有方案。