_g_matrix.c
Upload User: gzelex
Upload Date: 2007-01-07
Package Size: 707k
Code Size: 1k
Development Platform:

MultiPlatform

  1. /*******************************************************************************
  2. +
  3. +  LEDA-R  3.2.3
  4. +
  5. +  _g_matrix.c
  6. +
  7. +  Copyright (c) 1995  by  Max-Planck-Institut fuer Informatik
  8. +  Im Stadtwald, 66123 Saarbruecken, Germany     
  9. +  All rights reserved.
  10. *******************************************************************************/
  11. #include <LEDA/graph.h>
  12. #include <LEDA/node_matrix.h>
  13. void Node_Matrix::init(const graph& G, int n, GenPtr x) 
  14. { g = (graph*)&G;
  15.   M.init(G,n,0);
  16.   for(int i=0;i<M.size();i++) 
  17.   { graph_map* gm = new graph_map(&G,n);
  18.     M.entry(i) = gm;
  19.     for(int j=0;j<gm->size();j++) 
  20.     { copy_entry(x);
  21.       gm->access(j) = x;
  22.      }
  23.    }
  24. }
  25. void Node_Matrix::init(const Node_Matrix& A) 
  26. { g = A.g;
  27.   int n = A.M.size();
  28.   M.init(*g,n,0);
  29.   for(int i=0;i<n;i++) 
  30.   { graph_map* gm = new graph_map(g,n);
  31.     M.entry(i) = gm;
  32.     graph_map* gma = A.M.inf(i);
  33.     for(int j=0;j<n;j++) 
  34.     { GenPtr x = gma->read(j);
  35.       copy_entry(x);
  36.       gm->access(j) = x;
  37.      }
  38.    }
  39. }
  40. void Node_Matrix::clear_entries()
  41. { for(int i=0;i<M.size();i++) 
  42.   { graph_map* gm = M.entry(i);
  43.     for(int j=0;j<gm->size();j++) 
  44.     { GenPtr x = gm->read(j);
  45.       clear_entry(x); 
  46.      }
  47.    }
  48. }
  49. Node_Matrix::~Node_Matrix()
  50. { for(int i=0; i<M.size();i++) 
  51.     delete M.entry(i); 
  52.  }