简体   繁体   English

Java-可以绘制基本的力导向无向图(顶点,边)吗?

[英]Java - Possible to draw a basic force-directed undirected Graph (Vertices, Edges)?

I am trying to create a class in Java that will extend another class called Graph. 我试图在Java中创建一个类,该类将扩展另一个名为Graph的类。

The outline of the graph class is as follows: 图类的概述如下:

  • Graph constructor 图构造器
  • adjacent(int i, int j) 相邻的(int i,int j)
  • addEdge, removeEdge methods addEdge,removeEdge方法
  • addVertex, removeVertex methods addVertex,removeVertex方法
  • neighbors method 邻居法
  • numOfEdges method numOfEdges方法
  • averageDegree method averageDegree方法
  • girth method 周长法

I want to know if it possible to draw a very very basic force-directed undirected graph in Java using the graph class that I have made. 我想知道是否有可能使用我制作的图类在Java中绘制非常基本的力导向无向图。 I want my graph to be visually pleasing! 我希望我的图表在视觉上令人愉悦!

If so, can anyone point me in the right direction? 如果是这样,谁能指出我正确的方向?

What is your question, exactly? 您到底要问什么? If you ask whether your class contains enough information to allow applying a force-based layout, then obviously, the answer is no: you at least need to represent the position of the nodes ^^ (eg using additional x and y nodal attributes). 如果您询问您的类是否包含足够的信息以允许应用基于力的布局,那么显然,答案是否定的:您至少需要表示节点^^的位置(例如,使用其他x和y节点属性)。

Regarding the algorithm itself, are you interested in the process of implementing it yourself, or just in the result: displaying your graph in a nice way? 关于算法本身,您是否对自己的实现过程感兴趣,还是对结果感兴趣:以一种不错的方式显示图形? In the former case, you could start by having a look at seminal papers such as ( Fruchterman & Reingold '91 ) or ( Kamada & Kawai '89 ). 在前一种情况下,您可以先看一些开创性的论文,例如( Fruchterman&Reingold '91 )或( Kamada&Kawai '89 )。 Both articles explicitly give the proposed algorithm. 这两篇文章都明确给出了所提出的算法。 In the latter case, you could have a look at existing implementations, there're so many of them. 在后一种情况下,您可以看一下现有的实现,其中有很多。 Maybe the most convenient for you would be Gephi 's layout-related class, since this open source software ( available on GitHub ) is itself written in Java. 也许最方便的是Gephi的与布局有关的类,因为该开源软件( 可在GitHub上使用 )本身是用Java编写的。

In any case, you can also have a look at the other SO posts related to this topic, such as Kamada & Kawai graph layout algorithm? 无论如何,您还可以查看与此主题相关的其他SO帖子,例如Kamada&Kawai图布局算法? or Force-directed graphing . 力导向图

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

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