| 482 | |
| 483 | template <typename K, typename V> |
| 484 | void SplayTree<K, V>::getDOT(std::ostream &o) |
| 485 | { |
| 486 | o << "digraph G{ graph[ordering = out];" << std::endl; |
| 487 | if (node_count_ == 1) |
| 488 | o << root_->first << ";" << std::endl; |
| 489 | else |
| 490 | { |
| 491 | for (auto it = begin(); it != end(); ++it) |
| 492 | { |
| 493 | // 1[label="1 (size=1)"]; |
| 494 | char out[30]; |
| 495 | sprintf(out, "%d[label=\"%d (size=%d)\"];", it->first, it->first, (int)it->size); |
| 496 | o << out << std::endl; |
| 497 | if (it->parent) |
| 498 | { |
| 499 | std::string type = (iterator(it->parent->right.get()) == it ? "right" : "left"); |
| 500 | o << it->parent->first << " -> " << it->first << "[label=\"" << type << "\"];" << std::endl; |
| 501 | } |
| 502 | } |
| 503 | } |
| 504 | o << "}" << std::endl; |
| 505 | } |
| 506 | |
| 507 | #endif |