#!/usr/bin/perl -w

# Copyright 2015 Kevin Ryde
#
# This file is part of Graph-Graph6.
#
# Graph-Graph6 is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 3, or (at your option) any later
# version.
#
# Graph-Graph6 is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along
# with Graph-Graph6.  If not, see <http://www.gnu.org/licenses/>.

use 5.005;
use strict;
use FindBin;
use List::Util 'min','max','sum';
use MyGraphs;

# uncomment this to run the ### lines
# use Smart::Comments;

{
  # ascii print rows downwards from 0

  require Graph::Maker::Hanoi;
  my $level = 3;
  my $graph = Graph::Maker->new('hanoi', level => $level, undirected => 1);
  print $graph->get_graph_attribute('name'),"\n";
  print "$graph\n";

  # Graph_view($graph);
  my @v = ($graph->has_vertex(0) ? 0 : '0'x$level);
  my @seen;
  while (@v) {
    print join('  ',@v),"\n";
    foreach my $v (@v) { $seen[$v] = 1; }
    
    @v = map {$graph->neighbours($_)} @v;
    # @v = map {sort {$a cmp $b} $graph->neighbours($_)} @v;
    ### @v
    @v = grep {! $seen[$_]} @v;
  }
  my $count = sum(map {$_//0} @seen);
  print "$count vertices\n";
  exit 0;
}



