Blame polymake-bliss.patch

Jerry James ba7c26
--- ./apps/topaz/src/isomorphic_complexes.cc.orig	2011-04-13 01:51:10.000000000 -0600
Jerry James ba7c26
+++ ./apps/topaz/src/isomorphic_complexes.cc	2013-01-10 11:05:09.551105078 -0700
Jerry James ba7c26
@@ -34,7 +34,7 @@ find_facet_vertex_permutations(perl::Obj
Jerry James ba7c26
    return graph::find_row_col_permutation(M1,M2);
Jerry James ba7c26
 }
Jerry James ba7c26
 
Jerry James ba7c26
-UserFunction4perl("CREDIT nauty\n\n"
Jerry James ba7c26
+UserFunction4perl("CREDIT bliss\n\n"
Jerry James ba7c26
                   "# @category Comparing\n"
Jerry James ba7c26
                   "# Determine whether two given complexes are combinatorially isomorphic.\n"
Jerry James ba7c26
                   "# The problem is reduced to graph isomorphism of the vertex-facet incidence graphs.\n"
Jerry James ba7c26
--- ./apps/topaz/src/bistellar.cc.orig	2011-05-11 04:34:18.000000000 -0600
Jerry James ba7c26
+++ ./apps/topaz/src/bistellar.cc	2013-01-10 11:05:09.551105078 -0700
Jerry James ba7c26
@@ -381,7 +381,7 @@ UserFunction4perl("# @category Producing
Jerry James ba7c26
                   "# @return SimplicialComplex",
Jerry James ba7c26
                   &bistellar_simplification,"bistellar_simplification(SimplicialComplex { rounds => undef, abs => 0,  obj => undef,  relax => undef, heat => undef, constant => 0, allow_rev_move=> 0, min_n_facets => undef, verbose => undef, seed => undef, quiet => 0, distribution => undef })");
Jerry James ba7c26
 
Jerry James ba7c26
-UserFunction4perl("CREDIT nauty\n\n"
Jerry James ba7c26
+UserFunction4perl("CREDIT bliss\n\n"
Jerry James ba7c26
                   "# @category Comparing"
Jerry James ba7c26
                   "# Tries to determine wheter two complexes are pl-homeomorphic by using"
Jerry James ba7c26
                   "#  bistellar flips and a simulated annealing strategy."
Jerry James ba7c26
--- ./apps/graph/src/graph_compare.cc.orig	2010-12-12 16:36:28.000000000 -0700
Jerry James ba7c26
+++ ./apps/graph/src/graph_compare.cc	2013-01-10 11:05:09.560103386 -0700
Jerry James ba7c26
@@ -15,150 +15,137 @@
Jerry James ba7c26
    $Project: polymake $$Id: graph_compare.cc 9991 2010-12-12 23:36:28Z gawrilow $
Jerry James ba7c26
 */
Jerry James ba7c26
 
Jerry James ba7c26
-#define graph nauty_graph
Jerry James ba7c26
-#define set nauty_set
Jerry James ba7c26
-#define permutation nauty_permutation
Jerry James ba7c26
-
Jerry James ba7c26
-#include <nauty.h>
Jerry James ba7c26
-
Jerry James ba7c26
-namespace {
Jerry James ba7c26
-inline nauty_set* graph_row(nauty_graph *g, int v, int m) { return GRAPHROW(g,v,m); }
Jerry James ba7c26
-}
Jerry James ba7c26
-
Jerry James ba7c26
-#undef GRAPHROW
Jerry James ba7c26
-#undef graph
Jerry James ba7c26
-#undef set
Jerry James ba7c26
-#undef permutation
Jerry James ba7c26
-
Jerry James ba7c26
+#include <cstring>
Jerry James ba7c26
+#include <bliss/graph.hh>
Jerry James ba7c26
 #include "polymake/graph/graph_compare.h"
Jerry James ba7c26
 
Jerry James ba7c26
 namespace polymake { namespace graph {
Jerry James ba7c26
-namespace {
Jerry James ba7c26
-
Jerry James ba7c26
-DEFAULTOPTIONS_GRAPH(default_options);
Jerry James ba7c26
-NautyGraph *in_processing=0;
Jerry James ba7c26
 
Jerry James ba7c26
-}
Jerry James ba7c26
-
Jerry James ba7c26
-struct NautyGraph::impl {
Jerry James ba7c26
-   int n, m;
Jerry James ba7c26
-   nauty_graph *src_graph, *canon_graph;
Jerry James ba7c26
-   int *orbits, *canon_labels, *partitions;
Jerry James ba7c26
-   optionblk options;
Jerry James ba7c26
+struct BlissGraph::impl {
Jerry James ba7c26
+   bliss::AbstractGraph *src_graph;
Jerry James ba7c26
+   unsigned int *canon_labels;
Jerry James ba7c26
+   bool digraph;
Jerry James ba7c26
 
Jerry James ba7c26
-   explicit impl(int n_arg)
Jerry James ba7c26
-      : n(n_arg), m((n + WORDSIZE - 1) / WORDSIZE),
Jerry James ba7c26
-        src_graph(0), canon_graph(0),
Jerry James ba7c26
-        orbits(0), canon_labels(0), partitions(0)
Jerry James ba7c26
+   explicit impl(int n_arg, bool dir) : digraph(dir)
Jerry James ba7c26
    {
Jerry James ba7c26
-      src_graph=new nauty_graph[n*m];
Jerry James ba7c26
-      EMPTYSET(src_graph,n*m);
Jerry James ba7c26
-      canon_graph=new nauty_graph[n*m];
Jerry James ba7c26
-      orbits=new int[n];
Jerry James ba7c26
-      canon_labels=new int[n];
Jerry James ba7c26
-      partitions=new int[n];
Jerry James ba7c26
-      options=default_options;
Jerry James ba7c26
+      if (dir)
Jerry James ba7c26
+         src_graph = new bliss::Digraph(n_arg);
Jerry James ba7c26
+      else
Jerry James ba7c26
+         src_graph = new bliss::Graph(n_arg);
Jerry James ba7c26
+      canon_labels=new unsigned int[n_arg];
Jerry James ba7c26
    }
Jerry James ba7c26
 
Jerry James ba7c26
    ~impl()
Jerry James ba7c26
    {
Jerry James ba7c26
-      delete[] partitions;
Jerry James ba7c26
       delete[] canon_labels;
Jerry James ba7c26
-      delete[] orbits;
Jerry James ba7c26
-      delete[] canon_graph;
Jerry James ba7c26
-      delete[] src_graph;
Jerry James ba7c26
+      delete src_graph;
Jerry James ba7c26
    }
Jerry James ba7c26
 
Jerry James ba7c26
-   static void store_autom(int n_autom, nauty_permutation *perm, int*, int, int, int n)
Jerry James ba7c26
+   static void store_autom(void *graph, unsigned int n, const unsigned int *aut)
Jerry James ba7c26
    {
Jerry James ba7c26
-      in_processing->n_autom=n_autom;
Jerry James ba7c26
-      in_processing->autom.push_back( Array<int>(n, perm) );
Jerry James ba7c26
+      BlissGraph *g=reinterpret_cast<BlissGraph *>(graph);
Jerry James ba7c26
+      g->n_autom++;
Jerry James ba7c26
+      g->autom.push_back( Array<unsigned int>(n, aut) );
Jerry James ba7c26
    }
Jerry James ba7c26
 };
Jerry James ba7c26
 
Jerry James ba7c26
-NautyGraph::impl* NautyGraph::alloc_impl(int n, bool dir)
Jerry James ba7c26
+BlissGraph::impl* BlissGraph::alloc_impl(int n, bool dir)
Jerry James ba7c26
 {
Jerry James ba7c26
-   impl* i=new impl(n);
Jerry James ba7c26
-   i->options.digraph=dir;
Jerry James ba7c26
-   i->options.getcanon=true;
Jerry James ba7c26
-   return i;
Jerry James ba7c26
+   return new impl(n, dir);
Jerry James ba7c26
 }
Jerry James ba7c26
 
Jerry James ba7c26
-NautyGraph::~NautyGraph() { delete p_impl; }
Jerry James ba7c26
+BlissGraph::~BlissGraph() { delete p_impl; }
Jerry James ba7c26
 
Jerry James ba7c26
-void NautyGraph::add_edge(int from, int to)
Jerry James ba7c26
+void BlissGraph::add_edge(unsigned int from, unsigned int to)
Jerry James ba7c26
 {
Jerry James ba7c26
-   nauty_set *gv=graph_row(p_impl->src_graph, from, p_impl->m);
Jerry James ba7c26
-   ADDELEMENT(gv, to);
Jerry James ba7c26
+   if (p_impl->digraph) {
Jerry James ba7c26
+      bliss::Digraph *g = reinterpret_cast<bliss::Digraph *>(p_impl->src_graph);
Jerry James ba7c26
+      g->add_edge(from, to);
Jerry James ba7c26
+   } else {
Jerry James ba7c26
+      bliss::Graph *g = reinterpret_cast<bliss::Graph *>(p_impl->src_graph);
Jerry James ba7c26
+      g->add_edge(from, to);
Jerry James ba7c26
+   }
Jerry James ba7c26
 }
Jerry James ba7c26
 
Jerry James ba7c26
-void NautyGraph::partition(int at)
Jerry James ba7c26
+void BlissGraph::color(unsigned int at, unsigned int color)
Jerry James ba7c26
 {
Jerry James ba7c26
-   p_impl->options.defaultptn=false;
Jerry James ba7c26
-   std::fill(p_impl->partitions, p_impl->partitions+p_impl->n-1, 1);
Jerry James ba7c26
-   copy(entire(sequence(0,p_impl->n)), p_impl->canon_labels);
Jerry James ba7c26
-   p_impl->partitions[at-1]=0;
Jerry James ba7c26
-   p_impl->partitions[p_impl->n-1]=0;
Jerry James ba7c26
+   if (p_impl->digraph) {
Jerry James ba7c26
+      bliss::Digraph *g = reinterpret_cast<bliss::Digraph *>(p_impl->src_graph);
Jerry James ba7c26
+      g->change_color(at, color);
Jerry James ba7c26
+   } else {
Jerry James ba7c26
+      bliss::Graph *g = reinterpret_cast<bliss::Graph *>(p_impl->src_graph);
Jerry James ba7c26
+      g->change_color(at, color);
Jerry James ba7c26
+   }
Jerry James ba7c26
 }
Jerry James ba7c26
 
Jerry James ba7c26
-int* NautyGraph::partitions()
Jerry James ba7c26
+void BlissGraph::color(unsigned int from, unsigned int to, unsigned int color)
Jerry James ba7c26
 {
Jerry James ba7c26
-   p_impl->options.defaultptn=false;
Jerry James ba7c26
-   return p_impl->partitions;
Jerry James ba7c26
+   if (p_impl->digraph) {
Jerry James ba7c26
+      bliss::Digraph *g = reinterpret_cast<bliss::Digraph *>(p_impl->src_graph);
Jerry James ba7c26
+      for (unsigned int i = from; i < to; i++)
Jerry James ba7c26
+         g->change_color(i, color);
Jerry James ba7c26
+   } else {
Jerry James ba7c26
+      bliss::Graph *g = reinterpret_cast<bliss::Graph *>(p_impl->src_graph);
Jerry James ba7c26
+      for (unsigned int i = from; i < to; i++)
Jerry James ba7c26
+         g->change_color(i, color);
Jerry James ba7c26
+   }
Jerry James ba7c26
 }
Jerry James ba7c26
 
Jerry James ba7c26
-int* NautyGraph::labels()
Jerry James ba7c26
+void BlissGraph::partition(unsigned int at)
Jerry James ba7c26
 {
Jerry James ba7c26
-   return p_impl->canon_labels;
Jerry James ba7c26
+   color(0U, at, 0U);
Jerry James ba7c26
+   color(at, p_impl->src_graph->get_nof_vertices(), 1U);
Jerry James ba7c26
 }
Jerry James ba7c26
 
Jerry James ba7c26
-void NautyGraph::finalize(bool gather_automorphisms)
Jerry James ba7c26
+void BlissGraph::finalize(bool gather_automorphisms)
Jerry James ba7c26
 {
Jerry James ba7c26
-   statsblk stats;
Jerry James ba7c26
-   const int worksize=100*1024*1024;    // 100MB
Jerry James ba7c26
-   nauty_set *workspace=new nauty_set[worksize];
Jerry James ba7c26
+   bliss::Stats stats;
Jerry James ba7c26
+   size_t n=p_impl->src_graph->get_nof_vertices();
Jerry James ba7c26
+   const unsigned int *perm;
Jerry James ba7c26
+
Jerry James ba7c26
    if (gather_automorphisms) {
Jerry James ba7c26
-      p_impl->options.userautomproc=&impl::store_autom;
Jerry James ba7c26
-      in_processing=this;
Jerry James ba7c26
+      n_autom=0;
Jerry James ba7c26
+      perm=p_impl->src_graph->canonical_form(stats, &impl::store_autom, this);
Jerry James ba7c26
+   } else {
Jerry James ba7c26
+      perm=p_impl->src_graph->canonical_form(stats, NULL, NULL);
Jerry James ba7c26
    }
Jerry James ba7c26
-   nauty(p_impl->src_graph, p_impl->canon_labels, p_impl->partitions, 0, p_impl->orbits,
Jerry James ba7c26
-         &p_impl->options, &stats, workspace, worksize, p_impl->m, p_impl->n, p_impl->canon_graph);
Jerry James ba7c26
-   delete[] workspace;
Jerry James ba7c26
+   std::memcpy(p_impl->canon_labels, perm, n * sizeof(unsigned int));
Jerry James ba7c26
 }
Jerry James ba7c26
 
Jerry James ba7c26
-bool NautyGraph::operator== (const NautyGraph& g2) const
Jerry James ba7c26
+bool BlissGraph::operator== (const BlissGraph& g2) const
Jerry James ba7c26
 {
Jerry James ba7c26
-   if (p_impl->n != g2.p_impl->n) return false;
Jerry James ba7c26
-   nauty_set *cg1=p_impl->canon_graph, *cg1_end=cg1+p_impl->n*p_impl->m, *cg2=g2.p_impl->canon_graph;
Jerry James ba7c26
-   return std::equal(cg1, cg1_end, cg2);
Jerry James ba7c26
+   size_t n=p_impl->src_graph->get_nof_vertices();
Jerry James ba7c26
+   return n == g2.p_impl->src_graph->get_nof_vertices() &&
Jerry James ba7c26
+      !std::memcmp(p_impl->canon_labels, g2.p_impl->canon_labels,
Jerry James ba7c26
+                   n * sizeof(unsigned int));
Jerry James ba7c26
 }
Jerry James ba7c26
 
Jerry James ba7c26
-Array<int> NautyGraph::find_permutation(const NautyGraph& g2) const
Jerry James ba7c26
+Array<unsigned int> BlissGraph::find_permutation(const BlissGraph& g2) const
Jerry James ba7c26
 {
Jerry James ba7c26
    if (*this != g2)
Jerry James ba7c26
       throw no_match("not isomorphic");
Jerry James ba7c26
 
Jerry James ba7c26
-   Array<int> perm(p_impl->n);
Jerry James ba7c26
-   for (int *dst=perm.begin(), *lab1=p_impl->canon_labels, *lab1_end=lab1+p_impl->n, *lab2=g2.p_impl->canon_labels;
Jerry James ba7c26
+   Array<unsigned int> perm(p_impl->src_graph->get_nof_vertices());
Jerry James ba7c26
+   for (unsigned int *dst=perm.begin(), *lab1=p_impl->canon_labels, *lab1_end=lab1+p_impl->src_graph->get_nof_vertices(), *lab2=g2.p_impl->canon_labels;
Jerry James ba7c26
         lab1
Jerry James ba7c26
       dst[*lab2]=*lab1;
Jerry James ba7c26
    return perm;
Jerry James ba7c26
 }
Jerry James ba7c26
 
Jerry James ba7c26
-std::pair< Array<int>, Array<int> >
Jerry James ba7c26
-NautyGraph::find_permutations(const NautyGraph& g2, int n_cols) const
Jerry James ba7c26
+std::pair< Array<unsigned int>, Array<unsigned int> >
Jerry James ba7c26
+BlissGraph::find_permutations(const BlissGraph& g2, int n_cols) const
Jerry James ba7c26
 {
Jerry James ba7c26
    if (*this != g2)
Jerry James ba7c26
       throw no_match("not isomorphic");
Jerry James ba7c26
 
Jerry James ba7c26
-   Array<int> row_perm(p_impl->n-n_cols), col_perm(n_cols);
Jerry James ba7c26
+   Array<unsigned int> row_perm(p_impl->src_graph->get_nof_vertices()-n_cols), col_perm(n_cols);
Jerry James ba7c26
 
Jerry James ba7c26
-   int *lab1=p_impl->canon_labels, *lab1_end=lab1+n_cols, *lab2=g2.p_impl->canon_labels;
Jerry James ba7c26
-   for (int *dst=col_perm.begin(); lab1
Jerry James ba7c26
+   unsigned int *lab1=p_impl->canon_labels, *lab1_end=lab1+n_cols, *lab2=g2.p_impl->canon_labels;
Jerry James ba7c26
+   for (unsigned int *dst=col_perm.begin(); lab1
Jerry James ba7c26
       dst[*lab2]=*lab1;
Jerry James ba7c26
 
Jerry James ba7c26
-   lab1_end=p_impl->canon_labels+p_impl->n;
Jerry James ba7c26
-   for (int *dst=row_perm.begin(); lab1
Jerry James ba7c26
+   lab1_end=p_impl->canon_labels+p_impl->src_graph->get_nof_vertices();
Jerry James ba7c26
+   for (unsigned int *dst=row_perm.begin(); lab1
Jerry James ba7c26
       dst[*lab2-n_cols]=*lab1-n_cols;
Jerry James ba7c26
 
Jerry James ba7c26
    return std::make_pair(row_perm, col_perm);
Jerry James ba7c26
--- ./apps/graph/src/Makefile.inc.orig	2010-12-12 16:36:28.000000000 -0700
Jerry James ba7c26
+++ ./apps/graph/src/Makefile.inc	2013-01-10 11:05:54.870160960 -0700
Jerry James ba7c26
@@ -1,9 +1,7 @@
Jerry James ba7c26
 ifndef ExtensionTop
Jerry James ba7c26
-  ExternalLibs := nauty
Jerry James ba7c26
-
Jerry James ba7c26
-  graph_compare$O : ExtraCXXFLAGS = -DBIGNAUTY -I${BuildDir}/external/nauty
Jerry James ba7c26
+  graph_compare$O : ExtraCXXFLAGS = -DBLISS_USE_GMP
Jerry James ba7c26
 
Jerry James ba7c26
-  LIBS += ${BuildDir}/external/nauty/libnauty$A
Jerry James ba7c26
+  LIBS += -lbliss
Jerry James ba7c26
 endif
Jerry James ba7c26
 
Jerry James ba7c26
 # Local Variables:
Jerry James ba7c26
--- ./apps/graph/rules/comparing.rules.orig	2011-04-20 16:30:42.000000000 -0600
Jerry James ba7c26
+++ ./apps/graph/rules/comparing.rules	2013-01-10 11:05:09.552104890 -0700
Jerry James ba7c26
@@ -14,12 +14,12 @@
Jerry James ba7c26
 #-------------------------------------------------------------------------------
Jerry James ba7c26
 #  $Project: polymake $$Id: comparing.rules 10159 2011-04-20 22:30:42Z paffenho $
Jerry James ba7c26
 
Jerry James ba7c26
-CREDIT nauty
Jerry James ba7c26
+CREDIT bliss
Jerry James ba7c26
   Computation of automorphism groups of graphs.
Jerry James ba7c26
-  Copyright by Brendan McKay.
Jerry James ba7c26
-  http://cs.anu.edu.au/~bdm/nauty/
Jerry James ba7c26
+  Copyright by Tommi Junttila and Petteri Kaski.
Jerry James ba7c26
+  http://www.tcs.hut.fi/Software/bliss/
Jerry James ba7c26
 
Jerry James ba7c26
-label nauty
Jerry James ba7c26
+label bliss
Jerry James ba7c26
 
Jerry James ba7c26
 # @category Comparing
Jerry James ba7c26
 # true if //graph1// and //graph2// are isomorphic.
Jerry James ba7c26
--- ./apps/graph/include/graph_compare.h.orig	2011-03-01 08:46:48.000000000 -0700
Jerry James ba7c26
+++ ./apps/graph/include/graph_compare.h	2013-01-10 11:05:09.552104890 -0700
Jerry James ba7c26
@@ -27,18 +27,18 @@
Jerry James ba7c26
 
Jerry James ba7c26
 namespace polymake { namespace graph {
Jerry James ba7c26
 
Jerry James ba7c26
-class NautyGraph {
Jerry James ba7c26
+class BlissGraph {
Jerry James ba7c26
    struct impl;
Jerry James ba7c26
    impl *p_impl;
Jerry James ba7c26
 
Jerry James ba7c26
    int n_autom;
Jerry James ba7c26
-   std::list< Array<int> > autom;
Jerry James ba7c26
+   std::list< Array<unsigned int> > autom;
Jerry James ba7c26
 
Jerry James ba7c26
    static impl *alloc_impl(int n_nodes, bool is_directed);
Jerry James ba7c26
-   void add_edge(int from, int to);
Jerry James ba7c26
-   void partition(int at);
Jerry James ba7c26
-   int* partitions();
Jerry James ba7c26
-   int* labels();
Jerry James ba7c26
+   void add_edge(unsigned int from, unsigned int to);
Jerry James ba7c26
+   void color(unsigned int at, unsigned int color);
Jerry James ba7c26
+   void color(unsigned int from, unsigned int to, unsigned int color);
Jerry James ba7c26
+   void partition(unsigned int at);
Jerry James ba7c26
    void finalize(bool gather_automorphisms);
Jerry James ba7c26
 
Jerry James ba7c26
    template <typename Matrix>
Jerry James ba7c26
@@ -70,10 +70,10 @@ class NautyGraph {
Jerry James ba7c26
    }
Jerry James ba7c26
 
Jerry James ba7c26
 public:
Jerry James ba7c26
-   NautyGraph() : p_impl(0) {}
Jerry James ba7c26
+   BlissGraph() : p_impl(0) {}
Jerry James ba7c26
 
Jerry James ba7c26
    template <typename Graph>
Jerry James ba7c26
-   explicit NautyGraph(const GenericGraph<Graph>& G, bool gather_automorphisms=false)
Jerry James ba7c26
+   explicit BlissGraph(const GenericGraph<Graph>& G, bool gather_automorphisms=false)
Jerry James ba7c26
       : p_impl(alloc_impl(G.nodes(), G.is_directed))
Jerry James ba7c26
    {
Jerry James ba7c26
       fill(G);
Jerry James ba7c26
@@ -82,11 +82,11 @@ public:
Jerry James ba7c26
 
Jerry James ba7c26
    // non-symmetrical incidence matrix
Jerry James ba7c26
    template <typename Matrix>
Jerry James ba7c26
-   explicit NautyGraph(const GenericIncidenceMatrix<Matrix>& M,
Jerry James ba7c26
+   explicit BlissGraph(const GenericIncidenceMatrix<Matrix>& M,
Jerry James ba7c26
                        typename pm::disable_if<bool, Matrix::is_symmetric>::type gather_automorphisms=false)
Jerry James ba7c26
       : p_impl(alloc_impl(M.rows()+M.cols(), false))
Jerry James ba7c26
    {
Jerry James ba7c26
-      int rnode=M.cols();
Jerry James ba7c26
+      unsigned int rnode=M.cols();
Jerry James ba7c26
       partition(rnode);
Jerry James ba7c26
       for (typename Entire< Rows< Matrix > >::const_iterator r=entire(rows(M));  !r.at_end();  ++r, ++rnode)
Jerry James ba7c26
          for (typename Entire< typename Matrix::row_type >::const_iterator c=entire(*r);  !c.at_end();  ++c) {
Jerry James ba7c26
@@ -98,20 +98,20 @@ public:
Jerry James ba7c26
 
Jerry James ba7c26
    // symmetrical incidence matrix
Jerry James ba7c26
    template <typename Matrix>
Jerry James ba7c26
-   explicit NautyGraph(const GenericIncidenceMatrix<Matrix>& M,
Jerry James ba7c26
+   explicit BlissGraph(const GenericIncidenceMatrix<Matrix>& M,
Jerry James ba7c26
                        typename pm::enable_if<bool, Matrix::is_symmetric>::type gather_automorphisms=false)
Jerry James ba7c26
       : p_impl(alloc_impl(M.rows(), true))
Jerry James ba7c26
    {
Jerry James ba7c26
       // there can be ones on the diagonal, which correspond loops in the graph;
Jerry James ba7c26
-      // nauty requires the graph to be declared as directed in this case
Jerry James ba7c26
+      // bliss requires the graph to be declared as directed in this case
Jerry James ba7c26
       fill(M);
Jerry James ba7c26
       finalize(gather_automorphisms);
Jerry James ba7c26
    }
Jerry James ba7c26
 
Jerry James ba7c26
-   ~NautyGraph();
Jerry James ba7c26
+   ~BlissGraph();
Jerry James ba7c26
 
Jerry James ba7c26
-   bool operator== (const NautyGraph& g2) const;
Jerry James ba7c26
-   bool operator!= (const NautyGraph& g2) const { return !operator==(g2); }
Jerry James ba7c26
+   bool operator== (const BlissGraph& g2) const;
Jerry James ba7c26
+   bool operator!= (const BlissGraph& g2) const { return !operator==(g2); }
Jerry James ba7c26
 
Jerry James ba7c26
 private:
Jerry James ba7c26
    static void incr_count(std::pair<int,int>& p)
Jerry James ba7c26
@@ -129,16 +129,16 @@ private:
Jerry James ba7c26
 
Jerry James ba7c26
 public:
Jerry James ba7c26
    template <typename Graph1, typename Colors1, typename Graph2, typename Colors2>
Jerry James ba7c26
-   static bool prepare_colored(NautyGraph& NG1, const GenericGraph<Graph1>& G1, const Colors1& colors1,
Jerry James ba7c26
-                               NautyGraph& NG2, const GenericGraph<Graph2>& G2, const Colors2& colors2);
Jerry James ba7c26
+   static bool prepare_colored(BlissGraph& NG1, const GenericGraph<Graph1>& G1, const Colors1& colors1,
Jerry James ba7c26
+                               BlissGraph& NG2, const GenericGraph<Graph2>& G2, const Colors2& colors2);
Jerry James ba7c26
    template <typename Graph, typename Colors>
Jerry James ba7c26
-   static bool prepare_colored(NautyGraph& NG, const GenericGraph<Graph>& G, const Colors& colors);
Jerry James ba7c26
+   static bool prepare_colored(BlissGraph& NG, const GenericGraph<Graph>& G, const Colors& colors);
Jerry James ba7c26
 
Jerry James ba7c26
-   Array<int> find_permutation(const NautyGraph& g2) const;
Jerry James ba7c26
-   std::pair< Array<int>, Array<int> > find_permutations(const NautyGraph& g2, int n_cols) const;
Jerry James ba7c26
+   Array<unsigned int> find_permutation(const BlissGraph& g2) const;
Jerry James ba7c26
+   std::pair< Array<unsigned int>, Array<unsigned int> > find_permutations(const BlissGraph& g2, int n_cols) const;
Jerry James ba7c26
 
Jerry James ba7c26
    int n_automorphisms() const { return n_autom; }
Jerry James ba7c26
-   const std::list< Array<int> >& automorphisms() const { return autom; }
Jerry James ba7c26
+   const std::list< Array<unsigned int> >& automorphisms() const { return autom; }
Jerry James ba7c26
 };
Jerry James ba7c26
 
Jerry James ba7c26
 template <typename Graph1, typename Graph2> inline
Jerry James ba7c26
@@ -147,7 +147,7 @@ bool isomorphic(const GenericGraph
Jerry James ba7c26
    if (G1.is_directed != G2.is_directed || G1.nodes() != G2.nodes())
Jerry James ba7c26
       return false;
Jerry James ba7c26
    if (G1.nodes()<=1) return true;
Jerry James ba7c26
-   NautyGraph NG1(G1), NG2(G2);
Jerry James ba7c26
+   BlissGraph NG1(G1), NG2(G2);
Jerry James ba7c26
    return NG1==NG2;
Jerry James ba7c26
 }
Jerry James ba7c26
 
Jerry James ba7c26
@@ -158,49 +158,49 @@ bool isomorphic(const GenericGraph
Jerry James ba7c26
    if (G1.is_directed != G2.is_directed || G1.nodes() != G2.nodes())
Jerry James ba7c26
       return false;
Jerry James ba7c26
    if (G1.nodes()<=1) return true;
Jerry James ba7c26
-   NautyGraph NG1, NG2;
Jerry James ba7c26
-   return NautyGraph::prepare_colored(NG1, G1, colors1, NG2, G2, colors2) && NG1==NG2;
Jerry James ba7c26
+   BlissGraph NG1, NG2;
Jerry James ba7c26
+   return BlissGraph::prepare_colored(NG1, G1, colors1, NG2, G2, colors2) && NG1==NG2;
Jerry James ba7c26
 }
Jerry James ba7c26
 
Jerry James ba7c26
 template <typename Graph1, typename Graph2> inline
Jerry James ba7c26
-Array<int> find_node_permutation(const GenericGraph<Graph1>& G1, const GenericGraph<Graph2>& G2)
Jerry James ba7c26
+Array<unsigned int> find_node_permutation(const GenericGraph<Graph1>& G1, const GenericGraph<Graph2>& G2)
Jerry James ba7c26
 {
Jerry James ba7c26
    if (G1.is_directed != G2.is_directed)
Jerry James ba7c26
       throw no_match("graphs of different kind");
Jerry James ba7c26
    if (G1.nodes() != G2.nodes())
Jerry James ba7c26
       throw no_match("graphs of different size");
Jerry James ba7c26
-   NautyGraph NG1(G1), NG2(G2);
Jerry James ba7c26
+   BlissGraph NG1(G1), NG2(G2);
Jerry James ba7c26
    return NG1.find_permutation(NG2);
Jerry James ba7c26
 }
Jerry James ba7c26
 
Jerry James ba7c26
 template <typename Graph1, typename Colors1, typename Graph2, typename Colors2> inline
Jerry James ba7c26
-Array<int> find_node_permutation(const GenericGraph<Graph1>& G1, const Colors1& colors1,
Jerry James ba7c26
+Array<unsigned int> find_node_permutation(const GenericGraph<Graph1>& G1, const Colors1& colors1,
Jerry James ba7c26
                                  const GenericGraph<Graph2>& G2, const Colors2& colors2)
Jerry James ba7c26
 {
Jerry James ba7c26
    if (G1.is_directed != G2.is_directed)
Jerry James ba7c26
       throw no_match("graphs of different kind");
Jerry James ba7c26
    if (G1.nodes() != G2.nodes())
Jerry James ba7c26
       throw no_match("graphs of different size");
Jerry James ba7c26
-   NautyGraph NG1, NG2;
Jerry James ba7c26
-   if (NautyGraph::prepare_colored(NG1, G1, colors1, NG2, G2, colors2))
Jerry James ba7c26
+   BlissGraph NG1, NG2;
Jerry James ba7c26
+   if (BlissGraph::prepare_colored(NG1, G1, colors1, NG2, G2, colors2))
Jerry James ba7c26
       return NG1.find_permutation(NG2);
Jerry James ba7c26
    else
Jerry James ba7c26
       throw no_match("different colors");
Jerry James ba7c26
 }
Jerry James ba7c26
 
Jerry James ba7c26
 template <typename Graph> inline
Jerry James ba7c26
-Array< Array<int> > automorphisms(const GenericGraph<Graph>& G)
Jerry James ba7c26
+Array< Array<unsigned int> > automorphisms(const GenericGraph<Graph>& G)
Jerry James ba7c26
 {
Jerry James ba7c26
-   NautyGraph NG(G, true);
Jerry James ba7c26
-   return Array< Array<int> >(NG.n_automorphisms(), NG.automorphisms().begin());
Jerry James ba7c26
+   BlissGraph NG(G, true);
Jerry James ba7c26
+   return Array< Array<unsigned int> >(NG.n_automorphisms(), NG.automorphisms().begin());
Jerry James ba7c26
 }
Jerry James ba7c26
 
Jerry James ba7c26
 template <typename Graph, typename Colors> inline
Jerry James ba7c26
-Array< Array<int> > automorphisms(const GenericGraph<Graph>& G, const Colors& colors)
Jerry James ba7c26
+Array< Array<unsigned int> > automorphisms(const GenericGraph<Graph>& G, const Colors& colors)
Jerry James ba7c26
 {
Jerry James ba7c26
-   NautyGraph NG;
Jerry James ba7c26
-   NautyGraph::prepare_colored(NG,G,colors);
Jerry James ba7c26
-   return Array< Array<int> >(NG.n_automorphisms(), NG.automorphisms().begin());
Jerry James ba7c26
+   BlissGraph NG;
Jerry James ba7c26
+   BlissGraph::prepare_colored(NG,G,colors);
Jerry James ba7c26
+   return Array< Array<unsigned int> >(NG.n_automorphisms(), NG.automorphisms().begin());
Jerry James ba7c26
 }
Jerry James ba7c26
 
Jerry James ba7c26
 template <typename Matrix1, typename Matrix2> inline
Jerry James ba7c26
@@ -210,49 +210,49 @@ isomorphic(const GenericIncidenceMatrix<
Jerry James ba7c26
    if (M1.rows() != M2.rows() || M1.cols() != M2.cols())
Jerry James ba7c26
       return false;
Jerry James ba7c26
    if (M1.rows()<=1) return true;
Jerry James ba7c26
-   NautyGraph NG1(M1), NG2(M2);
Jerry James ba7c26
+   BlissGraph NG1(M1), NG2(M2);
Jerry James ba7c26
    return NG1==NG2;
Jerry James ba7c26
 }
Jerry James ba7c26
 
Jerry James ba7c26
 template <typename Matrix1, typename Matrix2> inline
Jerry James ba7c26
-typename pm::enable_if< Array<int>, Matrix1::is_symmetric && Matrix2::is_symmetric>::type
Jerry James ba7c26
+typename pm::enable_if< Array<unsigned int>, Matrix1::is_symmetric && Matrix2::is_symmetric>::type
Jerry James ba7c26
 find_row_permutation(const GenericIncidenceMatrix<Matrix1>& M1, const GenericIncidenceMatrix<Matrix2>& M2)
Jerry James ba7c26
 {
Jerry James ba7c26
    if (M1.rows() != M2.rows())
Jerry James ba7c26
       throw no_match("matrices of different dimensions");
Jerry James ba7c26
-   NautyGraph NG1(M1), NG2(M2);
Jerry James ba7c26
+   BlissGraph NG1(M1), NG2(M2);
Jerry James ba7c26
    return NG1.find_permutation(NG2);
Jerry James ba7c26
 }
Jerry James ba7c26
 
Jerry James ba7c26
 template <typename Matrix1, typename Matrix2> inline
Jerry James ba7c26
-typename pm::enable_if< std::pair< Array<int>, Array<int> >, !Matrix1::is_symmetric && !Matrix2::is_symmetric>::type
Jerry James ba7c26
+typename pm::enable_if< std::pair< Array<unsigned int>, Array<unsigned int> >, !Matrix1::is_symmetric && !Matrix2::is_symmetric>::type
Jerry James ba7c26
 find_row_col_permutation(const GenericIncidenceMatrix<Matrix1>& M1, const GenericIncidenceMatrix<Matrix2>& M2)
Jerry James ba7c26
 {
Jerry James ba7c26
    if (M1.rows() != M2.rows() || M1.cols() != M2.cols())
Jerry James ba7c26
       throw no_match("matrices of different dimensions");
Jerry James ba7c26
-   NautyGraph NG1(M1), NG2(M2);
Jerry James ba7c26
+   BlissGraph NG1(M1), NG2(M2);
Jerry James ba7c26
    return NG1.find_permutations(NG2, M1.cols());
Jerry James ba7c26
 }
Jerry James ba7c26
 
Jerry James ba7c26
 template <typename Matrix> inline
Jerry James ba7c26
-typename pm::enable_if< Array< Array<int> >, Matrix::is_symmetric>::type
Jerry James ba7c26
+typename pm::enable_if< Array< Array<unsigned int> >, Matrix::is_symmetric>::type
Jerry James ba7c26
 automorphisms(const GenericIncidenceMatrix<Matrix>& M)
Jerry James ba7c26
 {
Jerry James ba7c26
-   NautyGraph NG(M, true);
Jerry James ba7c26
-   return Array< Array<int> >(NG.n_automorphisms(), NG.automorphisms().begin());
Jerry James ba7c26
+   BlissGraph NG(M, true);
Jerry James ba7c26
+   return Array< Array<unsigned int> >(NG.n_automorphisms(), NG.automorphisms().begin());
Jerry James ba7c26
 }
Jerry James ba7c26
 
Jerry James ba7c26
 template <typename Matrix>
Jerry James ba7c26
-typename pm::disable_if< Array< std::pair< Array<int>, Array<int> > >, Matrix::is_symmetric>::type
Jerry James ba7c26
+typename pm::disable_if< Array< std::pair< Array<unsigned int>, Array<unsigned int> > >, Matrix::is_symmetric>::type
Jerry James ba7c26
 automorphisms(const GenericIncidenceMatrix<Matrix>& M)
Jerry James ba7c26
 {
Jerry James ba7c26
-   NautyGraph NG(M, true);
Jerry James ba7c26
-   Array< std::pair< Array<int>, Array<int> > > result(NG.n_automorphisms());
Jerry James ba7c26
-   std::list< Array<int> >::const_iterator p=NG.automorphisms().begin();
Jerry James ba7c26
+   BlissGraph NG(M, true);
Jerry James ba7c26
+   Array< std::pair< Array<unsigned int>, Array<unsigned int> > > result(NG.n_automorphisms());
Jerry James ba7c26
+   std::list< Array<unsigned int> >::const_iterator p=NG.automorphisms().begin();
Jerry James ba7c26
    const int n_rows=M.rows(), n_cols=M.cols();
Jerry James ba7c26
    sequence rows(n_cols, n_rows), cols(0, n_cols);
Jerry James ba7c26
 
Jerry James ba7c26
-   for (Entire< Array< std::pair< Array<int>, Array<int> > > >::iterator r=entire(result); !r.at_end(); ++r, ++p) {
Jerry James ba7c26
+   for (Entire< Array< std::pair< Array<unsigned int>, Array<unsigned int> > > >::iterator r=entire(result); !r.at_end(); ++r, ++p) {
Jerry James ba7c26
       r->first.append(n_rows, translate(select(*p,rows), -n_cols).begin());
Jerry James ba7c26
       r->second.append(n_cols, select(*p,cols).begin());
Jerry James ba7c26
    }
Jerry James ba7c26
@@ -260,45 +260,31 @@ automorphisms(const GenericIncidenceMatr
Jerry James ba7c26
 }
Jerry James ba7c26
 
Jerry James ba7c26
 template <typename Graph1, typename Colors1, typename Graph2, typename Colors2>
Jerry James ba7c26
-bool NautyGraph::prepare_colored(NautyGraph& NG1, const GenericGraph<Graph1>& G1, const Colors1& colors1,
Jerry James ba7c26
-                                 NautyGraph& NG2, const GenericGraph<Graph2>& G2, const Colors2& colors2)
Jerry James ba7c26
+bool BlissGraph::prepare_colored(BlissGraph& NG1, const GenericGraph<Graph1>& G1, const Colors1& colors1,
Jerry James ba7c26
+                                 BlissGraph& NG2, const GenericGraph<Graph2>& G2, const Colors2& colors2)
Jerry James ba7c26
 {
Jerry James ba7c26
    const int n=G1.nodes();
Jerry James ba7c26
    NG1.p_impl=alloc_impl(n, G1.is_directed);
Jerry James ba7c26
    NG2.p_impl=alloc_impl(n, G2.is_directed);
Jerry James ba7c26
 
Jerry James ba7c26
    typedef Map<typename pm::identical<typename Colors1::value_type, typename Colors2::value_type>::type,
Jerry James ba7c26
-      std::pair<int, int> > color_map_type;
Jerry James ba7c26
+      unsigned int > color_map_type;
Jerry James ba7c26
    color_map_type color_map;
Jerry James ba7c26
+   unsigned int color_num = 0U;
Jerry James ba7c26
 
Jerry James ba7c26
    for (typename Entire<Colors1>::const_iterator c=entire(colors1); !c.at_end(); ++c)
Jerry James ba7c26
-      incr_count(color_map[*c]);
Jerry James ba7c26
-
Jerry James ba7c26
+      if (!color_map.exists(*c))
Jerry James ba7c26
+         color_map[*c]=color_num++;
Jerry James ba7c26
    for (typename Entire<Colors2>::const_iterator c=entire(colors2); !c.at_end(); ++c)
Jerry James ba7c26
-      if (--color_map[*c].second < 0)
Jerry James ba7c26
-         return false;
Jerry James ba7c26
-
Jerry James ba7c26
-   int *p1=NG1.partitions(), *l1=NG1.labels(), *l2=NG2.labels();
Jerry James ba7c26
-   int start=0;
Jerry James ba7c26
-
Jerry James ba7c26
-   for (typename color_map_type::iterator cm=color_map.begin(); !cm.at_end(); ++cm) {
Jerry James ba7c26
-      const int n_of_this_color=cm->second.first;
Jerry James ba7c26
-      cm->second.second=start;
Jerry James ba7c26
-      std::fill(p1, p1+n_of_this_color-1, 1);  p1+=n_of_this_color; p1[-1]=0;
Jerry James ba7c26
-      start+=n_of_this_color;
Jerry James ba7c26
-   }
Jerry James ba7c26
-   p1=NG1.partitions();
Jerry James ba7c26
-
Jerry James ba7c26
-   std::copy(p1, p1+n, NG2.partitions());
Jerry James ba7c26
+      if (!color_map.exists(*c))
Jerry James ba7c26
+         color_map[*c]=color_num++;
Jerry James ba7c26
 
Jerry James ba7c26
    for (typename pm::ensure_features<Colors1, pm::cons<pm::end_sensitive, pm::indexed> >::const_iterator
Jerry James ba7c26
-           c=ensure(colors1, (pm::cons<pm::end_sensitive, pm::indexed>*)0).begin(); !c.at_end(); ++c) 
Jerry James ba7c26
-      l1[first_index(color_map[*c])]=c.index();
Jerry James ba7c26
-
Jerry James ba7c26
+           c=ensure(colors1, (pm::cons<pm::end_sensitive, pm::indexed>*)0).begin(); !c.at_end(); ++c)
Jerry James ba7c26
+      NG1.color(c.index(), color_map[*c]);
Jerry James ba7c26
    for (typename pm::ensure_features<Colors2, pm::cons<pm::end_sensitive, pm::indexed> >::const_iterator
Jerry James ba7c26
            c=ensure(colors2, (pm::cons<pm::end_sensitive, pm::indexed>*)0).begin(); !c.at_end(); ++c) 
Jerry James ba7c26
-      l2[second_index(color_map[*c])]=c.index();
Jerry James ba7c26
-
Jerry James ba7c26
+      NG2.color(c.index(), color_map[*c]);
Jerry James ba7c26
 
Jerry James ba7c26
    NG1.fill(G1);  NG1.finalize(false);
Jerry James ba7c26
    NG2.fill(G2);  NG2.finalize(false);
Jerry James ba7c26
@@ -306,31 +292,22 @@ bool NautyGraph::prepare_colored(NautyGr
Jerry James ba7c26
 }
Jerry James ba7c26
 
Jerry James ba7c26
 template <typename Graph, typename Colors>
Jerry James ba7c26
-bool NautyGraph::prepare_colored(NautyGraph& NG, const GenericGraph<Graph>& G, const Colors& colors)
Jerry James ba7c26
+bool BlissGraph::prepare_colored(BlissGraph& NG, const GenericGraph<Graph>& G, const Colors& colors)
Jerry James ba7c26
 {
Jerry James ba7c26
    const int n=G.nodes();
Jerry James ba7c26
    NG.p_impl=alloc_impl(n, G.is_directed);
Jerry James ba7c26
 
Jerry James ba7c26
-   typedef Map<typename Colors::value_type, int > color_map_type;
Jerry James ba7c26
+   typedef Map<typename Colors::value_type, unsigned int > color_map_type;
Jerry James ba7c26
    color_map_type color_map;
Jerry James ba7c26
+   unsigned int color_num = 0U;
Jerry James ba7c26
 
Jerry James ba7c26
    for (typename Entire<Colors>::const_iterator c=entire(colors); !c.at_end(); ++c)
Jerry James ba7c26
-      ++color_map[*c];
Jerry James ba7c26
-   
Jerry James ba7c26
-
Jerry James ba7c26
-   int *p=NG.partitions(), *l=NG.labels();
Jerry James ba7c26
-   int start=0;
Jerry James ba7c26
-
Jerry James ba7c26
-   for (typename color_map_type::iterator cm=color_map.begin(); !cm.at_end(); ++cm) {
Jerry James ba7c26
-      const int n_of_this_color=cm->second;
Jerry James ba7c26
-      cm->second += start-n_of_this_color;
Jerry James ba7c26
-      start += n_of_this_color;
Jerry James ba7c26
-      std::fill(p, p+n_of_this_color-1, 1);  p+=n_of_this_color; p[-1]=0;
Jerry James ba7c26
-   }
Jerry James ba7c26
+      if (!color_map.exists(*c))
Jerry James ba7c26
+         color_map[*c]=color_num++;
Jerry James ba7c26
 
Jerry James ba7c26
    for (typename pm::ensure_features<Colors, pm::cons<pm::end_sensitive, pm::indexed> >::const_iterator
Jerry James ba7c26
            c=ensure(colors, (pm::cons<pm::end_sensitive, pm::indexed>*)0).begin(); !c.at_end(); ++c)
Jerry James ba7c26
-      l[color_map[*c]++]=c.index();
Jerry James ba7c26
+      NG.color(c.index(), color_map[*c]);
Jerry James ba7c26
 
Jerry James ba7c26
    NG.fill(G);  NG.finalize(true);
Jerry James ba7c26
    return true;
Jerry James ba7c26
--- ./apps/polytope/src/isomorphic_polytopes.cc.orig	2011-04-13 01:51:10.000000000 -0600
Jerry James ba7c26
+++ ./apps/polytope/src/isomorphic_polytopes.cc	2013-01-10 11:05:09.550105266 -0700
Jerry James ba7c26
@@ -40,7 +40,7 @@ find_facet_vertex_permutations(perl::Obj
Jerry James ba7c26
    return graph::find_row_col_permutation(M1,M2);
Jerry James ba7c26
 }
Jerry James ba7c26
 
Jerry James ba7c26
-UserFunction4perl("CREDIT nauty\n\n"
Jerry James ba7c26
+UserFunction4perl("CREDIT bliss\n\n"
Jerry James ba7c26
                   "# @category Comparing"
Jerry James ba7c26
                   "# Check whether the face lattices of two polytopes are isomorphic."
Jerry James ba7c26
                   "# The problem is reduced to graph isomorphism of the vertex-facet incidence graphs."
Jerry James ba7c26
--- ./apps/polytope/src/lattice_isomorphic_polytopes.cc.orig	2011-09-12 15:56:14.000000000 -0600
Jerry James ba7c26
+++ ./apps/polytope/src/lattice_isomorphic_polytopes.cc	2013-01-10 11:05:09.543106580 -0700
Jerry James ba7c26
@@ -88,7 +88,7 @@ Array< Array<int> > lattice_automorphism
Jerry James ba7c26
 }
Jerry James ba7c26
 
Jerry James ba7c26
 
Jerry James ba7c26
-UserFunction4perl("CREDIT nauty\n\n"
Jerry James ba7c26
+UserFunction4perl("CREDIT bliss\n\n"
Jerry James ba7c26
                   "# @category Comparing"
Jerry James ba7c26
                   "# Tests whether two smooth lattice polytopes are lattice equivalent"
Jerry James ba7c26
                   "# by comparing lattice distances between vertices and facets. "
Jerry James ba7c26
--- ./apps/polytope/src/congruent_polytopes.cc.orig	2011-04-13 01:51:10.000000000 -0600
Jerry James ba7c26
+++ ./apps/polytope/src/congruent_polytopes.cc	2013-01-10 11:05:09.543106580 -0700
Jerry James ba7c26
@@ -59,7 +59,7 @@ Scalar congruent(perl::Object p1, perl::
Jerry James ba7c26
    return graph::isomorphic(G1, dist1, G2, dist2) ? min1 : Scalar(0);
Jerry James ba7c26
 }
Jerry James ba7c26
 
Jerry James ba7c26
-UserFunctionTemplate4perl("CREDIT nauty\n\n"
Jerry James ba7c26
+UserFunctionTemplate4perl("CREDIT bliss\n\n"
Jerry James ba7c26
                           "# @category Comparing"
Jerry James ba7c26
                           "# Check whether two given polytopes //P1// and //P2// are congruent, i.e. whether"
Jerry James ba7c26
                           "# there is an affine isomorphism between them that is induced by a (possibly scaled) orthogonal matrix."