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/PowerSet.h"
20 #include "polymake/topaz/graph.h"
21 #include "polymake/topaz/complex_tools.h"
22 
23 namespace polymake { namespace topaz {
24 
dual_graph(const FacetList & C)25 Graph<> dual_graph(const FacetList& C)
26 {
27    Graph<> DG(C.size());
28 
29    for (auto facet=entire(C);  !facet.at_end();  ++facet)
30       for (auto face=entire(all_subsets_less_1(*facet)); !face.at_end();  ++face)
31          for (auto neighbor_facet=C.findSupersets(*face);  !neighbor_facet.at_end();  ++neighbor_facet)
32             if ( (&*facet != &*neighbor_facet) && (neighbor_facet->size() == facet->size()))
33                DG.edge(facet.index(), neighbor_facet.index());
34 
35    return DG;
36 }
37 
38 FunctionTemplate4perl("vertex_graph(*)");
39 Function4perl(&dual_graph, "dual_graph");
40 
41 } }
42 
43 // Local Variables:
44 // mode:C++
45 // c-basic-offset:3
46 // indent-tabs-mode:nil
47 // End:
48