22std::string quote(std::string
const& s) {
return R
"(")" + s + R"(")"; }
27 std::vector<std::pair<int, int>>
const& edges)
29 out <<
"digraph structs {\n";
30 out <<
" node[shape=record]\n";
31 for (
auto& spec : specs) {
32 std::string labels =
" xlabel=\"";
33 for (
auto&
label : spec.labels) {
34 labels += labels ==
" xlabel=\"" ?
"" :
",";
35 labels +=
label.value;
38 out << fmt::format(
" \"{}\" [label=\"{}\"{}];\n", spec.name, spec.name, labels !=
" xlabel=\"\"" ? labels :
"");
40 for (
auto& e : edges) {
41 out << fmt::format(
" \"{}\" -> \"{}\"\n", specs[e.first].name, specs[e.second].name);
49 out << R
"GRAPHVIZ(digraph structs {
52 std::map<std::string, std::string> outputChannel2Device;
53 std::map<std::string, unsigned int> outputChannel2Port;
55 for (
auto& spec : specs) {
57 out <<
" " << quote(
id) << R
"( [label="{{)";
58 bool firstInput =
true;
59 for (
auto&& input : spec.inputChannels) {
60 if (firstInput ==
false) {
64 out <<
"<" << input.name <<
">" << input.name;
67 auto totalChannels = spec.inputChannels.size() +
68 spec.outputChannels.size();
69 out <<
id <<
"(" << totalChannels <<
")";
71 bool firstOutput =
true;
72 for (
auto&&
output : spec.outputChannels) {
73 outputChannel2Device.insert(std::make_pair(
output.name,
id));
74 outputChannel2Port.insert(std::make_pair(
output.name,
output.port));
75 if (firstOutput ==
false) {
84 for (
auto& spec : specs) {
85 for (
auto& input : spec.inputChannels) {
87 auto outputName = input.name;
88 out <<
" " << quote(outputChannel2Device[outputName]) <<
":" << quote(outputName) <<
"-> " << quote(spec.id)
89 <<
":" << quote(input.name) << R
"( [label=")" << input.port << R"(")"
GLuint GLsizei const GLchar * label
Defining PrimaryVertex explicitly as messageable.
static void dumpDeviceSpec2Graphviz(std::ostream &, const Devices &specs)
Helper to dump a set of devices as a graphviz file.
static void dumpDataProcessorSpec2Graphviz(std::ostream &, const WorkflowSpec &specs, std::vector< std::pair< int, int > > const &edges={})
Helper to dump a workflow as a graphviz file.