Graph-Maker-Other

 view release on metacpan or  search on metacpan

xt/oeis/Catalans-oeis.t  view on Meta::CPAN

   max_count => 9,
   func => sub {
     my ($count) = @_;
     my @got;
     for (my $N = 1; @got < $count; $N++) {
       my $graph = Graph::Maker->new('Catalans', N => $N,
                                     rel_type => 'rotate_Bempty');
       push @got, scalar($graph->predecessorless_vertices);
     }
     return \@got;
   });
MyOEIS::compare_values
  (anum => 'A058987',   # Catalan - Motzkin
   name => "rotate_Bempty predecessorful",
   max_count => 9,
   func => sub {
     my ($count) = @_;
     my @got;
     for (my $N = 1; @got < $count; $N++) {
       my $graph = Graph::Maker->new('Catalans', N => $N,
                                     rel_type => 'rotate_Bempty');
       push @got, scalar($graph->predecessorful_vertices);
     }
     return \@got;
   });

MyOEIS::compare_values
  (anum => 'A001006',  # Motzkin
   name => "rotate_Bempty successorless",
   max_count => 9,
   func => sub {
     my ($count) = @_;
     my @got;
     for (my $N = 1; @got < $count; $N++) {
       my $graph = Graph::Maker->new('Catalans', N => $N,
                                     rel_type => 'rotate_Bempty');
       push @got, scalar($graph->successorless_vertices);
     }
     return \@got;
   });
MyOEIS::compare_values
  (anum => 'A058987',  # Catalan - Motzkin
   name => "rotate_Bempty successorful",
   max_count => 9,
   func => sub {
     my ($count) = @_;
     my @got;
     for (my $N = 1; @got < $count; $N++) {
       my $graph = Graph::Maker->new('Catalans', N => $N,
                                     rel_type => 'rotate_Bempty');
       push @got, scalar($graph->successorful_vertices);
     }
     return \@got;
   });


#------------------------------------------------------------------------------
# split = Kreweras

# A000272 n^(n-2) = split, maximal chains
# Kreweras page 348 corollary 5.2 maximal chains m^(m-2).
# And ref to the same from Y. Poupard, "Codage et Denombrement
# Diverse Structures Apparentees a Celle d'Arbre", Cahiers BURO, volume
# 16, 1970, pages 71-80.
#
MyOEIS::compare_values
  (anum => 'A000272',
   max_count => 9,
   func => sub {
     my ($count) = @_;
     my @got;
     for (my $N = 0; @got < $count; $N++) {
       my $graph = Graph::Maker->new('Catalans', N => $N,
                                     rel_type => 'split');
       push @got, MyGraphs::Graph_num_maximal_paths($graph);
     }
     return \@got;
   });
MyOEIS::compare_values
  (anum => 'A000272',
   max_count => 9,
   func => sub {
     my ($count) = @_;
     my @got;
     for (my $N = 0; @got < $count; $N++) {
       push @got, $N<2 ? 1 : $N**($N-2);
     }
     return \@got;
   });

# A002694 binomial(2n,n-2) = split, num edges
# checked against the graph in t/Catalans.t
MyOEIS::compare_values
  (anum => 'A002694',
   max_count => 9,
   func => sub {
     my ($count) = @_;
     my @got;
     for (my $N = 2; @got < $count; $N++) {
       push @got, binomial(2*$N,$N-2)
     }
     return \@got;
   });


#------------------------------------------------------------------------------
# rotate_rightarm

# A002057 num edges, 4/(N+2) * binomial(2N-1, N-2)
# cf in t/Catalans.t
MyOEIS::compare_values
  (anum => 'A002057',
   max_count => 9,
   func => sub {
     my ($count) = @_;
     my @got;
     for (my $N = 2; @got < $count; $N++) {
       my $graph = Graph::Maker->new('Catalans', N => $N,
                                     rel_type => 'rotate_rightarm');
       push @got, scalar($graph->edges);
     }



( run in 0.503 second using v1.01-cache-2.11-cpan-df04353d9ac )