Java GraphStream:更全面的教程介绍? 背景
我对Java GraphStream:更全面的教程介绍? 背景,java,eclipse,graphstream,Java,Eclipse,Graphstream,我对GraphStream和Java都是新手。但是,我确实有使用其他OOP语言的经验,如C++。我个人觉得GraphStream的教程非常稀少,例如API没有提到哪些布局算法是有效的。因此,我正在寻找一个更整合的教程 问题: 使用GraphStream,我希望能够执行以下基本操作: 将图形导入为.dgs 将图形导入为.csv 从自动布局更改为指定布局(请首先列出有效的布局) 更改所有边属性(例如,权重) 从s到t,最多找到n条长度为l或更短的路径 添加一个事件(例如,单击节点,获取用户关于该节
GraphStream
和Java
都是新手。但是,我确实有使用其他OOP语言的经验,如C++
。我个人觉得GraphStream
的教程非常稀少,例如API没有提到哪些布局算法是有效的。因此,我正在寻找一个更整合的教程
问题:
使用GraphStream
,我希望能够执行以下基本操作:
- 将图形导入为
.dgs
- 将图形导入为
.csv
- 从自动布局更改为指定布局(请首先列出有效的布局)
- 更改所有边属性(例如,权重)
- 从s到t,最多找到n条长度为l或更短的路径
- 添加一个事件(例如,单击节点,获取用户关于该节点要显示的路径长度的输入,适当修剪/增长)
gs-algo-1.3
、gs-core-1.3
、gs-openord-master
和gs-ui-1.3
//import anything I might need
import org.graphstream.graph.*;
import org.graphstream.graph.implementations.*;
import org.graphstream.stream.file.*;
import org.graphstream.algorithm.*;
import org.graphstream.ui.layout.*;
import java.io.IOException;
@SuppressWarnings("unused")
public class pleaseHelpMe {
public static void main(String args[]) throws IOException, InterruptedException {
//do something that was in some code somewhere...
//please explain
System.setProperty("org.graphstream.ui.renderer","org.graphstream.ui.j2dviewer.J2DGraphRenderer");
//instantiate a graph
Graph graph = new SingleGraph("thisGraphNeedsHelp");
graph.addAttribute("ui.antialias"); //this does something...
graph.addAttribute("ui.quality"); //this sounds less important...
graph.setAttribute("ui.stylesheet", "url(../myStyle.css);"); //get some style
//errors, errors everywhere
//OpenOrdLayout layout = new OpenOrdLayout();
//layout.init(graph);
//layout.compute();
//changing all edges layout.weight is not that simple
//graph.setAttribute("edges","layout.weight:4");
graph.dsiplay();//this just makes the canvas?
FileSource source = new FileSourceDGS(); //prep. to get a file
//make graph a sink of source to get the contents of the file
source.addSink(graph);
source.begin("../dgs_files/awesomeFile.dgs");//read the file? strange command name i.m.o. file below.
while(source.nextEvents()); //keep graph interactive? or is this the GraphStream version of readline?
source.end() //close file? or end interaction?
//find paths
//get user input
}
}
DGS文件
CSS文件
要求非现场材料在这里是离题的。你提出的具体问题看起来不错,但它们应该分为几个独立的问题。@chrylis我明白你的意思。然而,GraphStream的文档在人们能够使用它来学习之前是有点混乱的。标签
graphstream
已经存在,因此它显然不是第一个。我很乐意编写文档,但首先我需要了解它们的内部语法特性。
DGS004
null 0 0
an a ui.label:a
an b ui.label:b
an c ui.label:c
an d ui.label:d
an e ui.label:e
an f ui.label:f
ae a_c a > c
ae c_e c > e
ae e_a e > a
ae b_d b > d
ae d_f d > f
ae f_b f > b
ae f_a f > a
ae e_b e > b
ae d_c d > c
node:clicked {
fill-color: purple;
text-size: 16;
text-style: bold;
text-color: #FFF;
text-alignment: at-right;
text-padding: 3px, 2px;
text-background-mode: rounded-box;
text-background-color: #A7CC;
text-color: white;
text-offset: 5px, 0px;
}
node {
size: 20px;
shape: circle;
fill-color: #8facb4;
stroke-mode: plain;
stroke-color: black;
}
edge {
size: 2px;
fill-mode: plain;
/*changing edge layout here also doesn't work*/
}
/*edge:clicked isn't a thing... :( */