File: big_object_graph

package info (click to toggle)
polymake 4.12-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 35,992 kB
  • sloc: cpp: 168,768; perl: 43,375; javascript: 31,575; ansic: 3,007; java: 2,654; python: 633; sh: 268; xml: 117; makefile: 61
file content (33 lines) | stat: -rw-r--r-- 874 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Main::load_apps();

my %proto2node;

@ARGV==1 or die "usage: OUTFILE\n";

open my $out, ">", $ARGV[0]
  or die "can't create outfile $ARGV[0]: $!\n";

print $out <<'.';
digraph "Big Object Zoo" {
.

foreach my $app (Core::Application::list_loaded()) {
  foreach my $proto (@{$app->object_types}) {
    my $node_id="n".scalar(keys %proto2node);
    $proto2node{$proto}=$node_id;
    print $out "  $node_id [label=\"", $app->name, "::", $proto->full_name, "\"];\n";
  }
}

while (my ($proto, $to_node)=each %proto2node) {
  my %ancestors;
  @ancestors{grep { exists $proto2node{$_} } @{$proto->linear_isa}}=();
  foreach my $super (grep { exists $proto2node{$_} } @{$proto->linear_isa}) {
    delete @ancestors{@{$super->linear_isa}};
  }
  my $to_node=$proto2node{$proto};
  print $out "  $proto2node{$_} -> $to_node;\n" for keys %ancestors;
}

print $out "}\n";
close $out;