gravatar
deba@inf.elte.hu
deba@inf.elte.hu
Fix skip*() functions is GraphWriters (Ticket #107)
0 1 0
default
1 file changed with 108 insertions and 0 deletions:
↑ Collapse diff ↑
Show white space 6 line context
... ...
@@ -605,2 +605,3 @@
605 605
      LEMON_ASSERT(!_skip_nodes, "Multiple usage of skipNodes() member");
606
      _skip_nodes = true;
606 607
      return *this;
... ...
@@ -613,2 +614,3 @@
613 614
      LEMON_ASSERT(!_skip_arcs, "Multiple usage of skipArcs() member");
615
      _skip_arcs = true;
614 616
      return *this;
... ...
@@ -680,2 +682,26 @@
680 682

	
683
    void createNodeIndex() {
684
      _writer_bits::MapStorageBase<Node>* label = 0;
685
      for (typename NodeMaps::iterator it = _node_maps.begin();
686
	   it != _node_maps.end(); ++it) {
687
        if (it->first == "label") {
688
	  label = it->second;
689
	  break;
690
	}
691
      }
692

	
693
      if (label == 0) {
694
	for (NodeIt n(_digraph); n != INVALID; ++n) {
695
	  std::ostringstream os;
696
	  os << _digraph.id(n);
697
	  _node_index.insert(std::make_pair(n, os.str()));	  
698
	}	
699
      } else {
700
	for (NodeIt n(_digraph); n != INVALID; ++n) {
701
	  std::string value = label->get(n);	  
702
	  _node_index.insert(std::make_pair(n, value));
703
	}
704
      }
705
    }
706

	
681 707
    void writeArcs() {
... ...
@@ -747,2 +773,26 @@
747 773

	
774
    void createArcIndex() {
775
      _writer_bits::MapStorageBase<Arc>* label = 0;
776
      for (typename ArcMaps::iterator it = _arc_maps.begin();
777
	   it != _arc_maps.end(); ++it) {
778
        if (it->first == "label") {
779
	  label = it->second;
780
	  break;
781
	}
782
      }
783

	
784
      if (label == 0) {
785
	for (ArcIt a(_digraph); a != INVALID; ++a) {
786
	  std::ostringstream os;
787
	  os << _digraph.id(a);
788
	  _arc_index.insert(std::make_pair(a, os.str()));	  
789
	}	
790
      } else {
791
	for (ArcIt a(_digraph); a != INVALID; ++a) {
792
	  std::string value = label->get(a);	  
793
	  _arc_index.insert(std::make_pair(a, value));
794
	}
795
      }
796
    }
797

	
748 798
    void writeAttributes() {
... ...
@@ -773,2 +823,4 @@
773 823
	writeNodes();
824
      } else {
825
	createNodeIndex();
774 826
      }
... ...
@@ -776,2 +828,4 @@
776 828
	writeArcs();
829
      } else {
830
	createArcIndex();
777 831
      }
... ...
@@ -1117,2 +1171,3 @@
1117 1171
      LEMON_ASSERT(!_skip_nodes, "Multiple usage of skipNodes() member");
1172
      _skip_nodes = true;
1118 1173
      return *this;
... ...
@@ -1125,2 +1180,3 @@
1125 1180
      LEMON_ASSERT(!_skip_edges, "Multiple usage of skipEdges() member");
1181
      _skip_edges = true;
1126 1182
      return *this;
... ...
@@ -1192,2 +1248,26 @@
1192 1248

	
1249
    void createNodeIndex() {
1250
      _writer_bits::MapStorageBase<Node>* label = 0;
1251
      for (typename NodeMaps::iterator it = _node_maps.begin();
1252
	   it != _node_maps.end(); ++it) {
1253
        if (it->first == "label") {
1254
	  label = it->second;
1255
	  break;
1256
	}
1257
      }
1258

	
1259
      if (label == 0) {
1260
	for (NodeIt n(_graph); n != INVALID; ++n) {
1261
	  std::ostringstream os;
1262
	  os << _graph.id(n);
1263
	  _node_index.insert(std::make_pair(n, os.str()));	  
1264
	}	
1265
      } else {
1266
	for (NodeIt n(_graph); n != INVALID; ++n) {
1267
	  std::string value = label->get(n);	  
1268
	  _node_index.insert(std::make_pair(n, value));
1269
	}
1270
      }
1271
    }
1272

	
1193 1273
    void writeEdges() {
... ...
@@ -1259,2 +1339,26 @@
1259 1339

	
1340
    void createEdgeIndex() {
1341
      _writer_bits::MapStorageBase<Edge>* label = 0;
1342
      for (typename EdgeMaps::iterator it = _edge_maps.begin();
1343
	   it != _edge_maps.end(); ++it) {
1344
        if (it->first == "label") {
1345
	  label = it->second;
1346
	  break;
1347
	}
1348
      }
1349

	
1350
      if (label == 0) {
1351
	for (EdgeIt e(_graph); e != INVALID; ++e) {
1352
	  std::ostringstream os;
1353
	  os << _graph.id(e);
1354
	  _edge_index.insert(std::make_pair(e, os.str()));	  
1355
	}	
1356
      } else {
1357
	for (EdgeIt e(_graph); e != INVALID; ++e) {
1358
	  std::string value = label->get(e);	  
1359
	  _edge_index.insert(std::make_pair(e, value));
1360
	}
1361
      }
1362
    }
1363

	
1260 1364
    void writeAttributes() {
... ...
@@ -1285,2 +1389,4 @@
1285 1389
	writeNodes();
1390
      } else {
1391
	createNodeIndex();
1286 1392
      }
... ...
@@ -1288,2 +1394,4 @@
1288 1394
	writeEdges();
1395
      } else {
1396
	createEdgeIndex();
1289 1397
      }
0 comments (0 inline)