1.1 --- a/src/include/oldgraph.h Thu Dec 11 07:24:53 2003 +0000
1.2 +++ b/src/include/oldgraph.h Sat Dec 13 15:44:50 2003 +0000
1.3 @@ -111,51 +111,52 @@
1.4 public:
1.5 int NodeNum() {return nodenum;};
1.6 int EdgeNum();
1.7 - int MaxNode() {return nodes_size;};
1.8 - int FirstNode() {return firstnode;};
1.9 - int NextNode(int n) {return nodes[n].next;};
1.10 - int PrevNode(int n) {return nodes[n].prev;};
1.11 - N& operator()(int n) {return *(N*)(nodes[n].data);};
1.12 - N& Data (int n) {return *(N*)(nodes[n].data);};
1.13 + int MaxNode() const {return nodes_size;};
1.14 + int FirstNode() const {return firstnode;};
1.15 + int NextNode(int n) const {return nodes[n].next;};
1.16 + int PrevNode(int n) const {return nodes[n].prev;};
1.17 + N& operator()(int n) const {return *(N*)(nodes[n].data);};
1.18 + N& Data (int n) const {return *(N*)(nodes[n].data);};
1.19 int AddNode();
1.20 - void AddNodeBlock(int n) {for(int i=0;i<n;i++) AddNode();}
1.21 + void AddNodeBlock(int n) const {for(int i=0;i<n;i++) AddNode();}
1.22 int AddNode(int n);
1.23 void Delete(int n);
1.24 - int isaNode(int n) {return n>=0&&n<nodes_size&&nodes[n].indeg!=FREE_NODE;};
1.25 + int isaNode(int n) const
1.26 + {return n>=0&&n<nodes_size&&nodes[n].indeg!=FREE_NODE;};
1.27
1.28 - int InDeg(int n) {return nodes[n].indeg;};
1.29 - int OutDeg(int n) {return nodes[n].outdeg;};
1.30 - EdgePoint FirstIn(int n) {return nodes[n].firstin;};
1.31 - EdgePoint FirstOut(int n) {return nodes[n].firstout;};
1.32 + int InDeg(int n) const {return nodes[n].indeg;};
1.33 + int OutDeg(int n) const {return nodes[n].outdeg;};
1.34 + EdgePoint FirstIn(int n) const {return nodes[n].firstin;};
1.35 + EdgePoint FirstOut(int n) const {return nodes[n].firstout;};
1.36
1.37 - E& operator()(EdgePoint e) {return *(E*)(((edge_t*)e)->data);};
1.38 - E& Data (EdgePoint e) {return *(E*)(((edge_t*)e)->data);};
1.39 - int From(EdgePoint e) {return e->from;};
1.40 - int To(EdgePoint e) {return e->to;};
1.41 - EdgePoint NextIn(EdgePoint e)
1.42 + E& operator()(EdgePoint e) const {return *(E*)(((edge_t*)e)->data);};
1.43 + E& Data (EdgePoint e) const {return *(E*)(((edge_t*)e)->data);};
1.44 + int From(EdgePoint e) const {return e->from;};
1.45 + int To(EdgePoint e) const {return e->to;};
1.46 + EdgePoint NextIn(EdgePoint e) const
1.47 {return e->nextin;};
1.48 - EdgePoint NextOut(EdgePoint e)
1.49 + EdgePoint NextOut(EdgePoint e)const
1.50 {return e->nextout;};
1.51 EdgePoint AddEdge(int f, int t);
1.52 void Delete(EdgePoint e);
1.53 EdgePoint Edge(int f,int t);
1.54 // EdgePoint Edge(E &d)
1.55 // {return (EdgePoint)(((char*)&d)-(char*)&(((edge_t*)NULL)->data));};
1.56 - E& operator()(int f, int t) {return *(E*)(((edge_t*)Edge(f,t))->data);};
1.57 - E& Data(int f, int t) {return *(E*)(((edge_t*)Edge(f,t))->data);};
1.58 + E& operator()(int f, int t) const {return *(E*)(((edge_t*)Edge(f,t))->data);};
1.59 + E& Data(int f, int t) const {return *(E*)(((edge_t*)Edge(f,t))->data);};
1.60 void Delete(int f, int t) {Delete(Edge(f,t));};
1.61 void Reverse(EdgePoint e);
1.62
1.63 // Functions for EdgeIndex
1.64
1.65 - EdgePoint Edge(EdgeIndex i)
1.66 + EdgePoint Edge(EdgeIndex i) const
1.67 { return (EdgePoint)(edges[i.block]->fields+i.index);};
1.68 - EdgeIndex Index(EdgePoint e) { return e->index;};
1.69 - EdgeIndex Index(int f, int t) { EdgePoint e; return Edge(f,t)->index; }
1.70 + EdgeIndex Index(EdgePoint e) const { return e->index;};
1.71 + EdgeIndex Index(int f, int t) const { EdgePoint e; return Edge(f,t)->index; }
1.72 void Delete(EdgeIndex i) { Delete(Edge(i));};
1.73 - E& operator()(EdgeIndex i)
1.74 + E& operator()(EdgeIndex i) const
1.75 {return *(E*)(edges[i.block]->fields[i.index].data);};
1.76 - E& Data(EdgeIndex i)
1.77 + E& Data(EdgeIndex i) const
1.78 {return *(E*)(edges[i.block]->fields[i.index].data);};
1.79 EdgePoint AddEdge(int f, int t,EdgeIndex in);
1.80
1.81 @@ -163,11 +164,11 @@
1.82
1.83 // Operators for symmetric graphs:
1.84
1.85 - EdgePoint FirstEdge(int n)
1.86 + EdgePoint FirstEdge(int n) const
1.87 { return (EdgePoint)(FirstIn(n)?FirstIn(n):FirstOut(n));};
1.88 - EdgePoint NextEdge(int n,EdgePoint e)
1.89 + EdgePoint NextEdge(int n,EdgePoint e) const
1.90 { return From(e)==n?NextOut(e):(NextIn(e)?NextIn(e):FirstOut(n)); };
1.91 - int Opposite(EdgePoint e,int n)
1.92 + int Opposite(EdgePoint e,int n) const
1.93 { return From(e)+To(e)-n; };
1.94
1.95 // Initializers, destructors
1.96 @@ -222,7 +223,6 @@
1.97
1.98 template<class N, class E> void OldGraph<N,E>::destroy()
1.99 {
1.100 - edge_block *oe;
1.101 int i;
1.102
1.103 while(firstnode!=INVALID) Delete(firstnode);