How to make recursive nodes?

I'm currently writing a graphs library in Java, and I would like a tool to visualize some graphs.

In my model, Graphs are composed of Nodes and Edges. Every Node have a certain number of Ports (I/O/IO) and Edges link those Ports together. Some special nodes are called GraphNodes and embed a Graph. The Ports of these GraphNodes are mapped to some Ports of the internal Nodes.

I'd like to provide several representation. The first of them, with which I am satisfied, is as follows: http://i.stack.imgur.com/ujU71.png

The input Ports are represented in green, the output ones in red, and the input-output ones in blue.

In this representation, the GraphNodes are not expanded and are displayed just as simple Nodes. In a second version, I would like to create something that looks like the following picture: http://i.stack.imgur.com/Cx624.png

The problem is that I can't manage to create a sub-graph (cluster) with fixed areas (it seems not to be possible). Another solution I tried was to embed a graph into a node. However, inserting some code into the part of a HTML label does not evaluate the code (here, the lt and gt signs are replaced by parenthesis, and spaces by dots, because I couldn't manage to make the code tag work):


....digraph graph0
....{
........node1
........[
............label =
............(
................(table border="0" cellspacing="0")
....................(tr)
........................(td cellpadding="0")
............................(table border="0" cellspacing="0")
................................(tr)
....................................(td bgcolor="palegreen" border="1" port="port2")port2(/td)
....................................(td bgcolor="palegreen" border="1" port="port3")port3(/td)
................................(/tr)
............................(/table)
........................(/td)
....................(/tr)
....................(tr)
........................(td cellpadding="0")
............................(table border="0" cellspacing="0")
................................(tr)
....................................(td cellpadding="0")
........................................(table border="0" cellspacing="0")
............................................(tr)
................................................(td bgcolor="skyblue" border="1" port="port5")port5(/td)
............................................(/tr)
........................................(/table)
....................................(/td)
....................................(td bgcolor="peachpuff" border="1")
........................................subgraph clusterTest
........................................{
............................................nodeTest
........................................}
....................................(/td)
................................(/tr)
............................(/table)
........................(/td)
....................(/tr)
....................(tr)
........................(td cellpadding="0")
............................(table border="0" cellspacing="0")
................................(tr)
....................................(td bgcolor="lightpink" border="1" port="port4")port4(/td)
................................(/tr)
............................(/table)
........................(/td)
....................(/tr)
................(/table)
............)
............style = "invisible"
........]
....}

The previous code creates the following graph: http://i.stack.imgur.com/E9jQ1.png

Finally, the best solution I can come up with is the following: http://i.stack.imgur.com/VzS5g.png

However I am not satisfied with it, because the GraphNodes' Ports are placed in strange locations sometimes.

Do you please know how I can reach the target graph layout? Please ask for any other information if needed.

Recent comments