#  Copyright (c) 1997-2004
#  Ewgenij Gawrilow, Michael Joswig (Technische Universitaet Berlin, Germany)
#  http://www.math.tu-berlin.de/polymake,  mailto:polymake@math.tu-berlin.de
#
#  This program 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 2, or (at your option) any
#  later version: http://www.gnu.org/licenses/gpl.txt.
#
#  This program 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.
#----------------------------------------------------------------------------
#  $Project: polymake $$Id: comparing.rules,v 1.6.2.1 2004/12/21 14:42:35 gawrilow Exp $

CONFIGURE : graph::check_iso

# category: Comparing
# args: Polytope1, Polytope2
# Check whether the face lattices of two polytopes are isomorphic.
# The problem is reduced to graph isomorphism of the vertex-facet incidence graphs.

user_function check_iso (Polytope,Polytope) {
   my ($p1, $p2)=@_;
   check_iso($p1->VERTICES_IN_FACETS, $p2->VERTICES_IN_FACETS,
	     $p1->N_VERTICES, $p2->N_VERTICES);
}


# category: Comparing
# args: Polytope1, Polytope2
# Check whether two given polytopes are congruent, i.e. whether
# there is an affine isomorphism between them that is induced by a (possibly scaled) orthogonal matrix.
#
# This function returns the scale factor, or 0 if the polytopes are not congruent.
#
# We are using the reduction of the congruence problem (for arbitrary point sets) to the graph
# isomorphism problem due to:
#
# Akutsu, T.: On determining the congruence of point sets in {`d`} dimensions.
#             Comput. Geom. Theory Appl. 9, 247--256 (1998), no. 4
#
# The construction is described in the documentation of the client @see congruence_graphs.

user_function check_congruence {
   my ($p1, $p2)=@_;
   my $dr=shared Poly::ProgramPipe($Modules::graph::dreadnaut);
   my $scale_factor=[ ];
   client("congruence_graphs", $p1, $p2, fileno($dr), $scale_factor);
   $scale_factor=$scale_factor->[0];
   if ($scale_factor != 0) {
      if (! Modules::graph::nauty_result($dr)) {
	 $scale_factor=0;
      }
   }
   return $scale_factor;
}


# Local Variables:
# mode: perl
# c-basic-offset:3
# End:
