Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

40
LINES

< > BotCompany Repo | #1007167 // Test GraphStream (network visualizer) [WORKS]

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Uses 970K of libraries. Click here for Pure Java version (67L/2K/2K).

!7

lib 1007168 // graphstream core 1.3

import org.graphstream.graph.*;

/*
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:
*/

import org.graphstream.graph.implementations.*;

p {
  // 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();
}

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1007167
Snippet name: Test GraphStream (network visualizer) [WORKS]
Eternal ID of this version: #1007167/4
Text MD5: 3ad00a11be02f9c907786cc1cc355366
Transpilation MD5: 7bbaf3a769920922975402faa8cc0a9f
Author: stefan
Category: javax / imaging
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-03-10 14:39:12
Source code size: 1932 bytes / 40 lines
Pitched / IR pitched: No / No
Views / Downloads: 421 / 493
Version history: 3 change(s)
Referenced in: [show references]