COIN-OR::LEMON - Graph Library

Changeset 3:272a5677bd6d in lemon-0.x for src/include/oldgraph.h


Ignore:
Timestamp:
12/13/03 16:44:50 (17 years ago)
Author:
Alpar Juttner
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@15
Message:
  • Marci type iterator constructors
  • src/demo/bfsdemo.cc: demo for bfs.h
  • cosmetical changes
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/include/oldgraph.h

    r1 r3  
    112112  int NodeNum() {return nodenum;};
    113113  int EdgeNum();
    114   int MaxNode() {return nodes_size;};
    115   int FirstNode() {return firstnode;};
    116   int NextNode(int n) {return nodes[n].next;};
    117   int PrevNode(int n) {return nodes[n].prev;};
    118   N& operator()(int n) {return *(N*)(nodes[n].data);};
    119   N& Data      (int n) {return *(N*)(nodes[n].data);};
     114  int MaxNode() const {return nodes_size;};
     115  int FirstNode() const {return firstnode;};
     116  int NextNode(int n) const {return nodes[n].next;};
     117  int PrevNode(int n) const {return nodes[n].prev;};
     118  N& operator()(int n) const {return *(N*)(nodes[n].data);};
     119  N& Data      (int n) const {return *(N*)(nodes[n].data);};
    120120  int AddNode();
    121   void AddNodeBlock(int n) {for(int i=0;i<n;i++) AddNode();}
     121  void AddNodeBlock(int n) const {for(int i=0;i<n;i++) AddNode();}
    122122  int AddNode(int n);
    123123  void Delete(int n);
    124   int isaNode(int n) {return n>=0&&n<nodes_size&&nodes[n].indeg!=FREE_NODE;};
    125  
    126   int InDeg(int n) {return nodes[n].indeg;};
    127   int OutDeg(int n) {return nodes[n].outdeg;};
    128   EdgePoint FirstIn(int n) {return nodes[n].firstin;};
    129   EdgePoint FirstOut(int n) {return nodes[n].firstout;};
    130 
    131   E& operator()(EdgePoint e) {return *(E*)(((edge_t*)e)->data);};
    132   E& Data      (EdgePoint e) {return *(E*)(((edge_t*)e)->data);};
    133   int From(EdgePoint e) {return e->from;};
    134   int To(EdgePoint e) {return e->to;};
    135   EdgePoint NextIn(EdgePoint e)
     124  int isaNode(int n) const
     125        {return n>=0&&n<nodes_size&&nodes[n].indeg!=FREE_NODE;};
     126 
     127  int InDeg(int n) const {return nodes[n].indeg;};
     128  int OutDeg(int n) const {return nodes[n].outdeg;};
     129  EdgePoint FirstIn(int n) const {return nodes[n].firstin;};
     130  EdgePoint FirstOut(int n) const {return nodes[n].firstout;};
     131
     132  E& operator()(EdgePoint e) const {return *(E*)(((edge_t*)e)->data);};
     133  E& Data      (EdgePoint e) const {return *(E*)(((edge_t*)e)->data);};
     134  int From(EdgePoint e) const {return e->from;};
     135  int To(EdgePoint e) const {return e->to;};
     136  EdgePoint NextIn(EdgePoint e) const
    136137    {return e->nextin;};
    137   EdgePoint NextOut(EdgePoint e)
     138  EdgePoint NextOut(EdgePoint e)const
    138139    {return e->nextout;};
    139140  EdgePoint AddEdge(int f, int t);
     
    142143  //  EdgePoint Edge(E &d)
    143144  //    {return (EdgePoint)(((char*)&d)-(char*)&(((edge_t*)NULL)->data));};
    144   E& operator()(int f, int t) {return *(E*)(((edge_t*)Edge(f,t))->data);};
    145   E& Data(int f, int t) {return *(E*)(((edge_t*)Edge(f,t))->data);};
     145  E& operator()(int f, int t) const {return *(E*)(((edge_t*)Edge(f,t))->data);};
     146  E& Data(int f, int t) const {return *(E*)(((edge_t*)Edge(f,t))->data);};
    146147  void Delete(int f, int t) {Delete(Edge(f,t));};
    147148  void Reverse(EdgePoint e);
     
    149150  // Functions for EdgeIndex
    150151 
    151   EdgePoint Edge(EdgeIndex i)
     152  EdgePoint Edge(EdgeIndex i) const
    152153    { return (EdgePoint)(edges[i.block]->fields+i.index);};
    153   EdgeIndex Index(EdgePoint e) { return e->index;};
    154   EdgeIndex Index(int f, int t) { EdgePoint e; return Edge(f,t)->index; }
     154  EdgeIndex Index(EdgePoint e) const { return e->index;};
     155  EdgeIndex Index(int f, int t) const { EdgePoint e; return Edge(f,t)->index; }
    155156  void Delete(EdgeIndex i) { Delete(Edge(i));};
    156   E& operator()(EdgeIndex i)
     157  E& operator()(EdgeIndex i) const
    157158     {return *(E*)(edges[i.block]->fields[i.index].data);};
    158   E& Data(EdgeIndex i)
     159  E& Data(EdgeIndex i) const
    159160     {return *(E*)(edges[i.block]->fields[i.index].data);};
    160161  EdgePoint AddEdge(int f, int t,EdgeIndex in);
     
    164165  // Operators for symmetric graphs:
    165166
    166   EdgePoint FirstEdge(int n)
     167  EdgePoint FirstEdge(int n) const
    167168    { return (EdgePoint)(FirstIn(n)?FirstIn(n):FirstOut(n));};
    168   EdgePoint NextEdge(int n,EdgePoint e)
     169  EdgePoint NextEdge(int n,EdgePoint e) const
    169170    { return From(e)==n?NextOut(e):(NextIn(e)?NextIn(e):FirstOut(n)); };
    170   int Opposite(EdgePoint e,int n)
     171  int Opposite(EdgePoint e,int n) const
    171172    { return From(e)+To(e)-n; };
    172173 
     
    223224template<class N, class E> void OldGraph<N,E>::destroy()
    224225{
    225   edge_block *oe;
    226226  int i;
    227227 
Note: See TracChangeset for help on using the changeset viewer.