1

I'd like to model a graph in GraphStream and render it with its Viewer, but my nodes need to have distinct input and output ports (preferably on the left-hand and right-hand side of the node box, respectively), and edges should connect with those ports rather than the node center.

Is that even possible in GraphStream? If not, is there another Java library that can be used? I know GraphViz Dot allows this, but I'd rather not call that by command line since that introduces an external dependency that's not part of my project.

EDIT: an example of the kind of thing I want to render (but for a very different domain): enter image description here

I'm perfectly willing to do the rendering myself, but of course I still need routing and coordinates for the nodes and edges.

Wouter Lievens
  • 4,019
  • 5
  • 41
  • 66

2 Answers2

2

There is no way in GraphStream yet to declare anchors, handles, or ports on the nodes.

However, since you want your edges tighten on the left and right sides of the nodes, then you might want to the give the "freeplan" CSS property a try. See the example below and especially the "stylesheet" attribute on the graph:

Graph graph = new SingleGraph("FreePlane");
System.setProperty("org.graphstream.ui.renderer", "org.graphstream.ui.j2dviewer.J2DGraphRenderer");
graph.display();
graph.setAttribute("stylesheet", "node { "
        + "     shape: rounded-box; "
        + "     padding: 5px; "
        + "     fill-color: white; "
        + "     stroke-mode: plain; "
        + "     size-mode: fit; "
        + "} "
        + "edge { "
        + "     shape: freeplane; "
        + "}");
graph.addAttribute("ui.quality");
graph.addAttribute("ui.antialias");

Node a = graph.addNode("A");
Node b = graph.addNode("B");
graph.addEdge("AB", "A", "B");
Node c = graph.addNode("C");
graph.addEdge("BC", "B", "C"); 

a.addAttribute("ui.label", "node A");
b.addAttribute("ui.label", "node B");
c.addAttribute("ui.label", "node C");

That would give you something like that : screeshot of the window generetaed by this code

Yoann
  • 556
  • 3
  • 11
  • Is there a way to "split up" a node, effectively making separate nodes for each port and then gluing them closely together somehow, respecting the left-right position? – Wouter Lievens Mar 31 '15 at 13:32
  • @WouterLievens well you *could* create multiple nodes indeed, but there would be no easy way to group them together. You would have to handle their position by yourself. You'll probably never achieve anything close to the figure you added in your post. It is actually difficult to expect that kind of feature from a general purpose graph library like GraphStream :( – Yoann Mar 31 '15 at 15:21
  • I understand that. It seems the focus in GraphStream is more on very big and/or dynamic graphs, rather than tiny complex graph structures. Which is fine, of course. Do you have any idea which (embeddable) java library might be suitable to handle the routing for graphs with ports on nodes? – Wouter Lievens Mar 31 '15 at 18:59
  • I am also facing similar visualisation graph issue. Are there any other frameworks which can handle nodes with ports or group of nodes visualization? – kensai Nov 18 '16 at 11:59
0

I wasn't able to achieve this with graphstream, but such functionality is supported by other frameworks like:

kensai
  • 943
  • 9
  • 16