1 /* Copyright (c) 1997-2021
2    Ewgenij Gawrilow, Michael Joswig, and the polymake team
3    Technische Universität Berlin, Germany
4    https://polymake.org
5 
6    This program is free software; you can redistribute it and/or modify it
7    under the terms of the GNU General Public License as published by the
8    Free Software Foundation; either version 2, or (at your option) any
9    later version: http://www.gnu.org/licenses/gpl.txt.
10 
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15 --------------------------------------------------------------------------------
16 */
17 
18 #include "polymake/client.h"
19 #include "polymake/topaz/complex_tools.h"
20 
21 namespace polymake { namespace topaz {
22 
is_closed_pseudo_manifold(const Lattice<BasicDecoration> & HD,bool known_pure)23 bool is_closed_pseudo_manifold(const Lattice<BasicDecoration>& HD, bool known_pure)
24 {
25    if (HD.in_degree(HD.top_node())==0)
26       return true;
27 
28    if (!known_pure && !is_pure(HD))
29       return false;
30 
31    for (const auto n : HD.nodes_of_rank(HD.rank()-2))
32       if (HD.out_degree(n) != 2)     // ridge contained in one facet only
33          return false;
34 
35    return true;
36 }
37 
is_closed_pseudo_manifold_client(BigObject p)38 void is_closed_pseudo_manifold_client(BigObject p)
39 {
40    const Lattice<BasicDecoration> &HD = p.give("HASSE_DIAGRAM");
41    p.take("CLOSED_PSEUDO_MANIFOLD") << is_closed_pseudo_manifold(HD,true);
42 }
43 
44 Function4perl(&is_closed_pseudo_manifold_client, "is_closed_pseudo_manifold(SimplicialComplex)");
45 
46 } }
47 
48 // Local Variables:
49 // mode:C++
50 // c-basic-offset:3
51 // indent-tabs-mode:nil
52 // End:
53