/* 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.
*/

#ident "$Project: polymake $$Id: ps_is_simplicial_impl.cc,v 1.2 2004/10/05 18:26:12 witte Exp $"


#include <ps_is_simplicial.h>

#include <ext/hash_set>

namespace polymake { namespace topaz {

   bool is_simplicial(const PseudoComplex& C) {
      const int dim = C.dim();
      std_ext::hash_set< Set<int> > faces;
      
      for (int d=0; d<=dim; ++d)
	 for (Entire< std::list<int> >::const_iterator f=entire(C.nodes_of_dim(d));
	      !f.at_end(); ++f) {
	    const Set<int>& face = C.node(*f);
	    std_ext::hash_set< Set<int> >::const_iterator find=faces.find(face);
	    if (find!=faces.end())  // face exists twice
	       return false;
	    else
	       faces.insert(face);
	 }

      return true;
   }
   
} }


// Local Variables:
// mode:C++
// c-basic-offset:3
// End:
