1 /* 2 This is wgraph.h 3 4 Coxeter version 3.0 Copyright (C) 2002 Fokko du Cloux 5 See file main.cpp for full copyright notice 6 */ 7 8 #ifndef WGRAPH_H /* guard against multiple inclusions */ 9 #define WGRAPH_H 10 11 #include "globals.h" 12 #include "list.h" 13 14 namespace wgraph { 15 using namespace coxeter; 16 using namespace list; 17 }; 18 19 /******** type declarations *************************************************/ 20 21 namespace wgraph { 22 class WGraph; 23 class OrientedGraph; 24 25 typedef Ulong Vertex; 26 typedef unsigned short Coeff; 27 typedef List<Coeff> CoeffList; 28 typedef Vertex Edge; 29 typedef List<Edge> EdgeList; 30 }; 31 32 /******** type definitions **************************************************/ 33 34 #include "bits.h" 35 #include "interface.h" 36 37 namespace wgraph { 38 using namespace bits; 39 using namespace interface; 40 41 class OrientedGraph { 42 private: 43 List<EdgeList> d_edge; 44 public: 45 /* constructors and destructors */ new(size_t size)46 void* operator new(size_t size) {return arena().alloc(size);} delete(void * ptr)47 void operator delete(void* ptr) 48 {return arena().free(ptr,sizeof(OrientedGraph));} OrientedGraph(const Ulong & n)49 OrientedGraph(const Ulong &n):d_edge(n) {}; 50 ~OrientedGraph(); 51 /* accessors */ 52 void cells(Partition& pi, OrientedGraph* P = 0) const; 53 const EdgeList& edge(const Vertex& x) const; /* inlined */ 54 Vertex firstMinimal(const BitMap& b) const; 55 void levelPartition(Partition& pi) const; 56 void print(FILE* file) const; 57 Ulong size() const; /* inlined */ 58 /* modifiers */ 59 EdgeList& edge(const Vertex& x); /* inlined */ 60 void permute(const Permutation& a); 61 void reset(); 62 void setSize(const Ulong& n); /* inlined */ 63 }; 64 65 class WGraph { 66 private: 67 OrientedGraph* d_graph; 68 List<CoeffList> d_coeff; 69 List<LFlags> d_descent; 70 public: 71 /* constructors and destructors */ new(size_t size)72 void* operator new(size_t size) {return arena().alloc(size);} delete(void * ptr)73 void operator delete(void* ptr) 74 {return arena().free(ptr,sizeof(WGraph));} 75 WGraph(const Ulong &n); 76 ~WGraph(); 77 /* accessors */ 78 const CoeffList& coeffList(const Vertex& x) const; /* inlined */ 79 const LFlags& descent(const Vertex& x) const; /* inlined */ 80 const EdgeList& edge(const Vertex& x) const; /* inlined */ 81 const OrientedGraph& graph() const; /* inlined */ 82 Ulong size() const; /* inlined */ 83 /* modifiers */ 84 CoeffList& coeffList(const Vertex& x); /* inlined */ 85 LFlags& descent(const Vertex& x); /* inlined */ 86 EdgeList& edge(const Vertex& x); /* inlined */ 87 OrientedGraph& graph(); /* inlined */ 88 void reset(); 89 void setSize(const Ulong& n); 90 /* input/output */ 91 void print(FILE* file, const Interface& I) const; 92 }; 93 coeffList(const Vertex & x)94 inline const CoeffList& WGraph::coeffList(const Vertex& x) const 95 {return d_coeff[x];} descent(const Vertex & x)96 inline const LFlags& WGraph::descent(const Vertex& x) const 97 {return d_descent[x];} edge(const Vertex & x)98 inline const EdgeList& WGraph::edge(const Vertex& x) const 99 {return d_graph->edge(x);} graph()100 inline const OrientedGraph& WGraph::graph() const {return *d_graph;} coeffList(const Vertex & x)101 inline CoeffList& WGraph::coeffList(const Vertex& x) {return d_coeff[x];} edge(const Vertex & x)102 inline EdgeList& WGraph::edge(const Vertex& x) {return d_graph->edge(x);} size()103 inline Ulong WGraph::size() const {return d_graph->size();} graph()104 inline OrientedGraph& WGraph::graph() {return *d_graph;} 105 descent(const Vertex & x)106 inline LFlags& WGraph::descent(const Vertex& x) {return d_descent[x];} edge(const Vertex & x)107 inline const EdgeList& OrientedGraph::edge(const Vertex& x) const 108 {return d_edge[x];} size()109 inline Ulong OrientedGraph::size() const {return d_edge.size();} edge(const Vertex & x)110 inline EdgeList& OrientedGraph::edge(const Vertex& x) {return d_edge[x];} setSize(const Ulong & n)111 inline void OrientedGraph::setSize(const Ulong& n) {d_edge.setSize(n);} 112 113 } 114 115 #endif 116