Perl代码

下面的例子展示了如何使用perl代码创建一个类似自动分割特性的布局;首先是Graph::Easy语言的表达:

  1. [A|B|C] [1]->[ABC.2]

perl代码如下:

  1. use Graph::Easy;
  2. my $g = Graph::Easy->new();
  3. my $a = $g->add_node('A');
  4. my $b = $g->add_node('B'); $b->relative_to($a, 1, 0);
  5. my $c = $g->add_node('C'); $c->relative_to($b, 1, 0);
  6. my $o = $g->add_node('1'); $g->add_edge($o,$c);
  7. print $g->as_ascii();

两种表达的输出如下:

  1. +---+
  2. | 1 |
  3. +---+
  4. |
  5. |
  6. v
  7. +---+---+----+
  8. | A | B | C |
  9. +---+---+----+