--- /dev/null
+#! /usr/bin/perl
+
+# Copyright (c) 2009, 2010 Nicira Networks
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+use strict;
+use warnings;
+
+my ($scale) = 1;
+print ".PS\n";
+print "linethick = 1;\n";
+while (<>) {
+ if (/graph (\S+) (\S+) (\S+)/) {
+ $scale = $1;
+ } elsif (my ($name, $x, $y, $width, $height, $label, $style, $shape, $color, $fillcolor) = /node (\S+) (\S+) (\S+) (\S+) (\S+) (\S+) (\S+) (\S+) (\S+) (\S+)/) {
+ $x *= $scale;
+ $y *= $scale;
+ $width *= $scale;
+ $height *= $scale;
+ print "box at $x,$y wid $width height $height \"$name\"\n";
+ } elsif (/edge/) {
+ my (undef, $tail, $head, $n, $rest) = split(' ', $_, 5);
+ my @xy;
+ for (1...$n) {
+ my ($x, $y);
+ ($x, $y, $rest) = split(' ', $rest, 3);
+ push(@xy, [$x * $scale, $y * $scale]);
+ }
+ my ($label, $xl, $yl);
+ if (scalar(my @junk = split(' ', $rest)) > 2) {
+ if ($rest =~ s/^"([^"]*)"\s+//) {
+ $label = $1;
+ } else {
+ ($label, $rest) = split(' ', $rest, 2);
+ }
+ ($xl, $yl, $rest) = split(' ', $rest, 3);
+ $xl *= $scale;
+ $yl *= $scale;
+ }
+ my ($style, $color) = split(' ', $rest);
+
+ print "spline -> from $xy[0][0],$xy[0][1]";
+ for (my ($i) = 0; $i <= $#xy; $i++) {
+ print " to $xy[$i][0],$xy[$i][1]";
+ }
+ print "\n";
+
+ print "\"$label\" at $xl,$yl\n" if defined($label);
+ }
+
+}
+print ".PE\n";