SDSL: Succinct Data Structure Library
A C++ template library for succinct data structures
|
00001 00002 00003 #ifndef INCLUDED_SDSL_TIKZ 00004 #define INCLUDED_SDSL_TIKZ 00005 00006 #include <string> 00007 #include <ostream> 00008 #include <iostream> 00009 #include <sdsl/util.hpp> 00010 00011 using std::string; 00012 using std::ostream; 00013 using std::endl; 00014 00015 namespace sdsl 00016 { 00017 00018 void begin_tikzpicture(ostream& out, string options=""); 00019 void end_tikzpicture(ostream& out); 00020 void begin_tikzscope(ostream& out, string options=""); 00021 void end_tikzscope(ostream& out); 00022 void tikz_node(ostream& out, string content="", string at="0,0", string name="", string options=""); 00023 void tikz_coordinate(ostream& out, string at="0,0", string name="", string option=""); 00024 00025 template<class T> 00026 void write_tikz_column_from_container(ostream& out, const T& vec, string name_prefix="i") 00027 { 00028 tikz_node(out, "", "0,0cm", name_prefix, "st_"+name_prefix); 00029 for (typename T::size_type i=0; i < vec.size(); ++i) { 00030 tikz_node(out, util::to_latex_string(vec[i]), name_prefix + "|- y" + util::to_string(i) , 00031 name_prefix+util::to_string(i), "st_elem_"+name_prefix); 00032 } 00033 } 00034 00035 template<class tContainer> 00036 void write_tikz_array(ostream& out, const tContainer& v, string array_name="", bool escape=false) 00037 { 00038 if (array_name != "") { 00039 out << "\\def\\" << array_name << "{%" << endl; 00040 } else { 00041 out << "{"; 00042 } 00043 for (typename tContainer::size_type i=0; i < v.size(); ++i) { 00044 if (i > 0) 00045 out << ","; 00046 string w = util::to_latex_string(v[i]); 00047 if (escape) { 00048 if (w.size() > 0 and w[0]=='\\') 00049 w = "\\noexpand"+w; 00050 out << "\"" << w << "\""; 00051 } else { 00052 out << w; 00053 } 00054 } 00055 out << "}"; 00056 if (array_name != "") { 00057 out << "%" << endl; 00058 } 00059 } 00060 00061 void write_y_column(ostream& out, size_t n); 00062 00063 } // end namespace 00064 #endif