2

I'm trying to generate layout information for a graph where all of the elements must be laid out in a grid. I would like all coordinates to be integer multiples of the grid-box size.

For example, if I have a grid made up of 1 inch squares, I would like all node coordinates to be a multiple of 72 (the number of points in an inch, if I'm not mistaken). I like the hierarchical layout of dot, so if possible, that's the tool I'd like to use.

I've looked over the element attribute list several times, and I haven't figured out how to do this.

Edit:

The reason I've chosen GraphViz is that it can perform layout, then return that information as text. Other tools seem to just want to render a graph, but I want to render it elsewhere, and I just need to get the layout information.

Nat Mote
  • 4,068
  • 18
  • 30

1 Answers1

1

I believe the Graph::Easy perl module can be used to layout dot files into grids.

http://bloodgate.com/perl/graph/manual/index.html

http://search.cpan.org/~tels/Graph-Easy/bin/graph-easy

Edit:

I'm not sure if this is your desired output, but by playing with the column width of the nodes I can produce:

+------------------+
|        A         |
+------------------+
  |             |
  |             |
  v             v
+------------++----+
|     A1     || A2 |
+------------++----+
  |      |
  |      |
  v      v
+-----++-----+
| A1B || A1A |
+-----++-----+

graph { flow: down; }
[ A ] {columns: 8;}
[ A ]  -> { start: south; end: north; } [ A1 ] 
[ A ]  -> { start: south; end: north; } [ A2 ] 
[ A1 ] -> { start: south; end: north;}  [ A1A ]
[ A1 ] -> { start: south; end: north;}  [ A1B ]

Also I believe it is possible to set the exact space on the grid that the node sits.

Finbar Crago
  • 432
  • 5
  • 12
  • I looked into Graph::Easy, but it doesn't seem able to do a hierarchical layout, which I need. I'm laying out a DAG, and I want child nodes to be strictly below their parents. – Nat Mote Aug 19 '11 at 03:49
  • It turns out that Graph::Easy isn't quite powerful enough for my needs. Your trick works well for small graphs, but once they get a little bigger it stops working. – Nat Mote Aug 19 '11 at 22:28