我正在尝试使用 JUNG 库来可视化带有顶点和边的基本图。使用网站上的示例代码,我有以下内容:
import edu.uci.ics.jung.graph.DirectedSparseGraph;
import edu.uci.ics.jung.graph.Graph;
import edu.uci.ics.jung.graph.UndirectedSparseGraph;
import java.util.*;
public class GraphTest {
public GraphTest(){
Graph g = new DirectedSparseGraph();
Vertex v1 = (Vertex) g.addVertex(new DirectedSparseVertex());
Vertex v2 = (Vertex) g.addVertex(new DirectedSparseVertex());
}
但是,“顶点”带有红色下划线,Netbeans 告诉我它找不到符号。我尝试导入 Netbeans 的建议但无济于事,现在我相信 Vertex 实际上是 Java 原生的。我不知道我要去哪里错了,但我认为这是一个基本的错误,正在逃避我。