diff --git a/subt_ign/src/dot_generator.cc b/subt_ign/src/dot_generator.cc index 16ac6f08..bce1a895 100644 --- a/subt_ign/src/dot_generator.cc +++ b/subt_ign/src/dot_generator.cc @@ -61,11 +61,12 @@ std::string parse(const std::string &_key, const std::string &_str) void printGraph(std::vector &_vertexData) { std::stringstream out; + out << "/* Visibility graph generated by dot_generator */\n\n"; out << "graph {\n"; - out << "/* ==== Vertices ==== */\n"; + out << " /* ==== Vertices ==== */\n\n"; // out << "0 [label=\"0::base_station::BaseStation\"]\n"; - for (auto &vd : _vertexData) + for (const auto &vd : _vertexData) { // update staging area name for compatibility with other subt tools that // rely on this naming convention @@ -77,11 +78,16 @@ void printGraph(std::vector &_vertexData) type = "base_station"; name = "BaseStation"; } - out << vd.id << " " << "[label=\"" << vd.id << "::" << type + out << " " << vd.id; + if (vd.id < 10) + out << " "; + out << " " << "[label=\"" << vd.id << "::" << type << "::" << name << "\"];\n"; + if (vd.id == 0) + out << std::endl; } - out << "/* ==== Edges ==== */\n"; + out << "\n /* ==== Edges ==== */\n\n"; for (unsigned int i = 0u; i < _vertexData.size() -1; ++i) { @@ -108,8 +114,13 @@ void printGraph(std::vector &_vertexData) else cost = 6; - out << _vertexData[i].id << " -- " << _vertexData[j].id - << " " << "[label=" << cost << "];\n"; + out << " " << _vertexData[i].id; + if (_vertexData[i].id < 10) + out << " "; + out << " -- " << _vertexData[j].id; + if (_vertexData[j].id < 10) + out << " "; + out << " " << "[label=" << cost << "];\n"; } } } @@ -196,7 +207,7 @@ void generateDOT(const std::string &_sdfFile) ////////////////////////////////////////////////// int main(int argc, char **argv) { - if (argc < 2) + if (argc != 2) { std::cerr << "Usage: dot_generator " << std::endl;