ez mar kafa
authormarci
Mon, 05 Apr 2004 17:10:25 +0000
changeset 30410d035c2e81c
parent 303 1b377a730d02
child 305 6720705c9095
ez mar kafa
src/work/list_graph.h
src/work/marci/iterator_bfs_demo.cc
     1.1 --- a/src/work/list_graph.h	Mon Apr 05 16:52:46 2004 +0000
     1.2 +++ b/src/work/list_graph.h	Mon Apr 05 17:10:25 2004 +0000
     1.3 @@ -44,7 +44,7 @@
     1.4        NodeMap(const ListGraph& _G, T a) : 
     1.5  	G(_G), container(G.node_id, a) { }
     1.6        void set(Node n, T a) { container[/*G.id(n)*/n.node->id]=a; }
     1.7 -      T get(Node n) const { return container[/*G.id(n)*/n.node->id]; }
     1.8 +//      T get(Node n) const { return container[/*G.id(n)*/n.node->id]; }
     1.9        typename std::vector<T>::reference operator[](Node n) { 
    1.10  	return container[/*G.id(n)*/n.node->id]; }
    1.11        typename std::vector<T>::const_reference operator[](Node n) const { 
    1.12 @@ -65,7 +65,7 @@
    1.13        EdgeMap(const ListGraph& _G, T a) : 
    1.14  	G(_G), container(G.edge_id, a) { }
    1.15        void set(Edge e, T a) { container[/*G.id(e)*/e.edge->id]=a; }
    1.16 -      T get(Edge e) const { return container[/*G.id(e)*/e.edge->id]; }
    1.17 +//      T get(Edge e) const { return container[/*G.id(e)*/e.edge->id]; }
    1.18        typename std::vector<T>::reference operator[](Edge e) { 
    1.19  	return container[/*G.id(e)*/e.edge->id]; } 
    1.20        typename std::vector<T>::const_reference operator[](Edge e) const { 
    1.21 @@ -267,15 +267,15 @@
    1.22      /* same methods in other style */
    1.23      /* for experimental purpose */
    1.24  
    1.25 -    NodeIt& /*getF*/first(NodeIt& v) const { 
    1.26 +    NodeIt& first(NodeIt& v) const { 
    1.27        v=NodeIt(*this); return v; }
    1.28 -    EdgeIt& /*getF*/first(EdgeIt& e) const { 
    1.29 +    EdgeIt& first(EdgeIt& e) const { 
    1.30        e=EdgeIt(*this); return e; }
    1.31 -    OutEdgeIt& /*getF*/first(OutEdgeIt& e, Node v) const { 
    1.32 +    OutEdgeIt& first(OutEdgeIt& e, Node v) const { 
    1.33        e=OutEdgeIt(*this, v); return e; }
    1.34 -    InEdgeIt& /*getF*/first(InEdgeIt& e, Node v) const { 
    1.35 +    InEdgeIt& first(InEdgeIt& e, Node v) const { 
    1.36        e=InEdgeIt(*this, v); return e; }
    1.37 -    SymEdgeIt& /*getF*/first(SymEdgeIt& e, Node v) const { 
    1.38 +    SymEdgeIt& first(SymEdgeIt& e, Node v) const { 
    1.39        e=SymEdgeIt(*this, v); return e; }
    1.40      //void getTail(Node& n, const Edge& e) const { n=tail(e); }
    1.41      //void getHead(Node& n, const Edge& e) const { n=head(e); }
    1.42 @@ -295,14 +295,14 @@
    1.43      template< typename It >
    1.44      It first() const { 
    1.45        It e;
    1.46 -      /*getF*/first(e);
    1.47 +      first(e);
    1.48        return e; 
    1.49      }
    1.50  
    1.51      template< typename It >
    1.52      It first(Node v) const { 
    1.53        It e;
    1.54 -      /*getF*/first(e, v);
    1.55 +      first(e, v);
    1.56        return e; 
    1.57      }
    1.58  
     2.1 --- a/src/work/marci/iterator_bfs_demo.cc	Mon Apr 05 16:52:46 2004 +0000
     2.2 +++ b/src/work/marci/iterator_bfs_demo.cc	Mon Apr 05 17:10:25 2004 +0000
     2.3 @@ -20,9 +20,9 @@
     2.4  public:
     2.5    EdgeNameMap(Graph& _graph, NodeNameMap& _node_name_map) : 
     2.6      graph(_graph), node_name_map(_node_name_map) { }
     2.7 -  string get(typename Graph::Edge e) const { 
     2.8 +  string operator[](typename Graph::Edge e) const { 
     2.9      return 
    2.10 -      (node_name_map.get(graph.tail(e))+"->"+node_name_map.get(graph.head(e)));
    2.11 +      (node_name_map[graph.tail(e)]+"->"+node_name_map[graph.head(e)]);
    2.12    }
    2.13  };
    2.14  
    2.15 @@ -95,13 +95,13 @@
    2.16      
    2.17      cout << "bfs and dfs iterator demo on the directed graph" << endl;
    2.18      for(GW::NodeIt n(gw); gw.valid(n); gw.next(n)) { 
    2.19 -      cout << node_name.get(n) << ": ";
    2.20 +      cout << node_name[n] << ": ";
    2.21        cout << "out edges: ";
    2.22        for(GW::OutEdgeIt e(gw, n); gw.valid(e); gw.next(e)) 
    2.23 -	cout << edge_name.get(e) << " ";
    2.24 +	cout << edge_name[e] << " ";
    2.25        cout << "in edges: ";
    2.26        for(GW::InEdgeIt e(gw, n); gw.valid(e); gw.next(e)) 
    2.27 -	cout << edge_name.get(e) << " ";
    2.28 +	cout << edge_name[e] << " ";
    2.29        cout << endl;
    2.30      }
    2.31  
    2.32 @@ -111,15 +111,15 @@
    2.33      while (!bfs.finished()) {
    2.34        //cout << "edge: ";
    2.35        if (gw.valid(bfs)) {
    2.36 -	cout << edge_name.get(bfs) << /*endl*/", " << 
    2.37 -	  node_name.get(gw.aNode(bfs)) << 
    2.38 +	cout << edge_name[bfs] << /*endl*/", " << 
    2.39 +	  node_name[gw.aNode(bfs)] << 
    2.40  	  (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 
    2.41 -	  node_name.get(gw.bNode(bfs)) << 
    2.42 +	  node_name[gw.bNode(bfs)] << 
    2.43  	  (bfs.isBNodeNewlyReached() ? ": is newly reached." : 
    2.44  	   ": is not newly reached.");
    2.45        } else { 
    2.46  	cout << "invalid" << /*endl*/", " << 
    2.47 -	  node_name.get(bfs.aNode()) << 
    2.48 +	  node_name[bfs.aNode()] << 
    2.49  	  (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 
    2.50  	  
    2.51  	  "invalid.";
    2.52 @@ -145,15 +145,15 @@
    2.53        ++dfs;
    2.54        //cout << "edge: ";
    2.55        if (gw.valid(dfs)) {
    2.56 -	cout << edge_name.get(dfs) << /*endl*/", " << 
    2.57 -	  node_name.get(gw.aNode(dfs)) << 
    2.58 +	cout << edge_name[dfs] << /*endl*/", " << 
    2.59 +	  node_name[gw.aNode(dfs)] << 
    2.60  	  (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 
    2.61 -	  node_name.get(gw.bNode(dfs)) << 
    2.62 +	  node_name[gw.bNode(dfs)] << 
    2.63  	  (dfs.isBNodeNewlyReached() ? ": is newly reached." : 
    2.64  	   ": is not newly reached.");
    2.65        } else { 
    2.66  	cout << "invalid" << /*endl*/", " << 
    2.67 -	  node_name.get(dfs.aNode()) << 
    2.68 +	  node_name[dfs.aNode()] << 
    2.69  	  (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 
    2.70  	  
    2.71  	  "invalid.";
    2.72 @@ -171,13 +171,13 @@
    2.73      
    2.74      cout << "bfs and dfs iterator demo on the reversed directed graph" << endl;
    2.75      for(GW::NodeIt n(gw); gw.valid(n); gw.next(n)) { 
    2.76 -      cout << node_name.get(n) << ": ";
    2.77 +      cout << node_name[n] << ": ";
    2.78        cout << "out edges: ";
    2.79        for(GW::OutEdgeIt e(gw, n); gw.valid(e); gw.next(e)) 
    2.80 -	cout << edge_name.get(e) << " ";
    2.81 +	cout << edge_name[e] << " ";
    2.82        cout << "in edges: ";
    2.83        for(GW::InEdgeIt e(gw, n); gw.valid(e); gw.next(e)) 
    2.84 -	cout << edge_name.get(e) << " ";
    2.85 +	cout << edge_name[e] << " ";
    2.86        cout << endl;
    2.87      }
    2.88  
    2.89 @@ -187,15 +187,15 @@
    2.90      while (!bfs.finished()) {
    2.91        //cout << "edge: ";
    2.92        if (gw.valid(bfs)) {
    2.93 -	cout << edge_name.get(bfs) << /*endl*/", " << 
    2.94 -	  node_name.get(gw.aNode(bfs)) << 
    2.95 +	cout << edge_name[bfs] << /*endl*/", " << 
    2.96 +	  node_name[gw.aNode(bfs)] << 
    2.97  	  (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 
    2.98 -	  node_name.get(gw.bNode(bfs)) << 
    2.99 +	  node_name[gw.bNode(bfs)] << 
   2.100  	  (bfs.isBNodeNewlyReached() ? ": is newly reached." : 
   2.101  	   ": is not newly reached.");
   2.102        } else { 
   2.103  	cout << "invalid" << /*endl*/", " << 
   2.104 -	  node_name.get(bfs.aNode()) << 
   2.105 +	  node_name[bfs.aNode()] << 
   2.106  	  (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 
   2.107  	  
   2.108  	  "invalid.";
   2.109 @@ -221,15 +221,15 @@
   2.110        ++dfs;
   2.111        //cout << "edge: ";
   2.112        if (gw.valid(dfs)) {
   2.113 -	cout << edge_name.get(dfs) << /*endl*/", " << 
   2.114 -	  node_name.get(gw.aNode(dfs)) << 
   2.115 +	cout << edge_name[dfs] << /*endl*/", " << 
   2.116 +	  node_name[gw.aNode(dfs)] << 
   2.117  	  (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 
   2.118 -	  node_name.get(gw.bNode(dfs)) << 
   2.119 +	  node_name[gw.bNode(dfs)] << 
   2.120  	  (dfs.isBNodeNewlyReached() ? ": is newly reached." : 
   2.121  	   ": is not newly reached.");
   2.122        } else { 
   2.123  	cout << "invalid" << /*endl*/", " << 
   2.124 -	  node_name.get(dfs.aNode()) << 
   2.125 +	  node_name[dfs.aNode()] << 
   2.126  	  (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 
   2.127  	  
   2.128  	  "invalid.";
   2.129 @@ -247,13 +247,13 @@
   2.130      
   2.131      cout << "bfs and dfs iterator demo on the undirected graph" << endl;
   2.132      for(GW::NodeIt n(gw); gw.valid(n); gw.next(n)) { 
   2.133 -      cout << node_name.get(n) << ": ";
   2.134 +      cout << node_name[n] << ": ";
   2.135        cout << "out edges: ";
   2.136        for(GW::OutEdgeIt e(gw, n); gw.valid(e); gw.next(e)) 
   2.137 -	cout << edge_name.get(e) << " ";
   2.138 +	cout << edge_name[e] << " ";
   2.139        cout << "in edges: ";
   2.140        for(GW::InEdgeIt e(gw, n); gw.valid(e); gw.next(e)) 
   2.141 -	cout << edge_name.get(e) << " ";
   2.142 +	cout << edge_name[e] << " ";
   2.143        cout << endl;
   2.144      }
   2.145  //     for(GW::EdgeIt e=gw.first<GW::EdgeIt>(); gw.valid(e); gw.next(e)) { 
   2.146 @@ -267,15 +267,15 @@
   2.147      while (!bfs.finished()) {
   2.148        //cout << "edge: ";
   2.149        if (gw.valid(GW::OutEdgeIt(bfs))) {
   2.150 -	cout << edge_name.get(GW::OutEdgeIt(bfs)) << /*endl*/", " << 
   2.151 -	  node_name.get(gw.aNode(bfs)) << 
   2.152 +	cout << edge_name[GW::OutEdgeIt(bfs)] << /*endl*/", " << 
   2.153 +	  node_name[gw.aNode(bfs)] << 
   2.154  	  (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 
   2.155 -	  node_name.get(gw.bNode(bfs)) << 
   2.156 +	  node_name[gw.bNode(bfs)] << 
   2.157  	  (bfs.isBNodeNewlyReached() ? ": is newly reached." : 
   2.158  	   ": is not newly reached.");
   2.159        } else { 
   2.160  	cout << "invalid" << /*endl*/", " << 
   2.161 -	  node_name.get(bfs.aNode()) << 
   2.162 +	  node_name[bfs.aNode()] << 
   2.163  	  (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 
   2.164  	  
   2.165  	  "invalid.";
   2.166 @@ -301,15 +301,15 @@
   2.167        ++dfs;
   2.168        //cout << "edge: ";
   2.169        if (gw.valid(GW::OutEdgeIt(dfs))) {
   2.170 -	cout << edge_name.get(GW::OutEdgeIt(dfs)) << /*endl*/", " << 
   2.171 -	  node_name.get(gw.aNode(dfs)) << 
   2.172 +	cout << edge_name[GW::OutEdgeIt(dfs)] << /*endl*/", " << 
   2.173 +	  node_name[gw.aNode(dfs)] << 
   2.174  	  (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 
   2.175 -	  node_name.get(gw.bNode(dfs)) << 
   2.176 +	  node_name[gw.bNode(dfs)] << 
   2.177  	  (dfs.isBNodeNewlyReached() ? ": is newly reached." : 
   2.178  	   ": is not newly reached.");
   2.179        } else { 
   2.180  	cout << "invalid" << /*endl*/", " << 
   2.181 -	  node_name.get(dfs.aNode()) << 
   2.182 +	  node_name[dfs.aNode()] << 
   2.183  	  (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") << 
   2.184  	  
   2.185  	  "invalid.";