Skip to content

Commit

Permalink
Altered output to reduce diff with old dot files
Browse files Browse the repository at this point in the history
  • Loading branch information
nkoenig committed Apr 8, 2020
1 parent 4f2e14c commit 31bf464
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions subt_ign/src/dot_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,12 @@ std::string parse(const std::string &_key, const std::string &_str)
void printGraph(std::vector<VertexData> &_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
Expand All @@ -77,11 +78,16 @@ void printGraph(std::vector<VertexData> &_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)
{
Expand All @@ -108,8 +114,13 @@ void printGraph(std::vector<VertexData> &_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";
}
}
}
Expand Down Expand Up @@ -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 <path_to_world_sdf_file>"
<< std::endl;
Expand Down

0 comments on commit 31bf464

Please sign in to comment.