如何在 ruby 中可视化哈希数据结构?
我有一个哈希对象,其结构类似于:
{:category1 =>
{:subcategory1 =>
[
{:article => "some article", :date => "2010-04-04"},
...
],
:subc2 => [...]
},
:category2 => {...},
...
}
How can I Visualize it as graph in ruby?
是否有一个简单的方法/gem/lib 可以将此哈希转换为 DOT?
I have a hash object, whose structure looks similar to this:
{:category1 =>
{:subcategory1 =>
[
{:article => "some article", :date => "2010-04-04"},
...
],
:subc2 => [...]
},
:category2 => {...},
...
}
How can I visualize it as graph in ruby?
Is there a simple method/gem/lib that converts this Hash to DOT?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为什么你想要它是一个图表?您的示例中的数据是一棵树。
您可以使用 Ruby 漂亮的打印方式轻松地在文本中看到树:
如果您想要更清晰的输出:
Why do you want it to be a graph? The data in your example is a tree.
You can see the tree easily in text with Ruby's pretty print:
If you want a little cleaner output:
我相信您可以使用 ruby-graphviz gem 进行此类可视化。
I believe you could use the ruby-graphviz gem for this sort of visualization.