import java.util.*; import java.util.zip.*; import java.util.List; import java.util.regex.*; import java.util.concurrent.*; import java.util.concurrent.atomic.*; import java.util.concurrent.locks.*; import javax.swing.*; import javax.swing.event.*; import javax.swing.text.*; import javax.swing.table.*; import java.io.*; import java.net.*; import java.lang.reflect.*; import java.lang.ref.*; import java.lang.management.*; import java.security.*; import java.security.spec.*; import java.awt.*; import java.awt.event.*; import java.awt.image.*; import javax.imageio.*; import java.math.*; import org.graphstream.graph.*; import org.graphstream.graph.implementations.*; public class main { // graphstream core 1.3 /* http://graphstream-project.org/doc/Tutorials/Getting-Started/ There exist several graph implementations, a versatile one is the SingleGraph class. It provides a 1-graph (there can be only one edge between two nodes), that can be either directed or undirected. In fact you can mix directed and undirected edges inside such a graph, simply consider undirected edges as bidirectional. This does not well cope with the mathematical definition, but is certainly easier to use for developing. You import it with: */ public static void main(final String[] args) throws Exception { // You create the graph this way: Graph graph = new SingleGraph("Tutorial 1"); /* There are lots of ways to populate a graph with nodes, edges and data attributes. In GraphStream the better way is to connect a graph event producer to the graph (such as a loader or graph generator). However the Graph class also provides a construction interface that allows to build the graph by hand. This interface is mostly useful to build small examples and to experiment with idea prototypes. The construction API of the graph works as a factory for node and edge elements (you cannot create nodes and edges by yourself and add them in the graph, you must ask the graph to create them for you). Add the following lines after the graph declaration: */ graph.addNode("A"); graph.addNode("B"); graph.addNode("C"); graph.addEdge("AB", "A", "B"); graph.addEdge("BC", "B", "C"); graph.addEdge("CA", "C", "A"); /* As their name suggest, these methods will add three nodes and three edges between the nodes. You can see that each node or edge is identified by a string. Such identifiers must naturally be unique. It is often useful to check the graph by seeing it, you can easily do this using the display() utility method: */ graph.display(); } }