gpt4 book ai didi

graphviz - 如何将点图转换为 json 图?

转载 作者:行者123 更新时间:2023-12-04 23:16:27 24 4
gpt4 key购买 nike

我想使用 sigma.js 来显示一些 DOT 图。但似乎 sigma.js 只支持 json 图形格式。

是否有一些 bash 工具或 javascript 模块可以将 DOT 图转换为 json 图?

例如从 DOT 图:

graph {
n1 [Label = "n1"];
n2 [Label = "n2"];
n3 [Label = "n3"];
n1 -- n2;
n1 -- n3;
n2 -- n2;
}


传输到 JSON 图:

{
"nodes": [
{
"id": "n0",
"label": "A node",
"x": 0,
"y": 0,
"size": 3
},
{
"id": "n1",
"label": "Another node",
"x": 3,
"y": 1,
"size": 2
},
{
"id": "n2",
"label": "And a last one",
"x": 1,
"y": 3,
"size": 1
}
],
"edges": [
{
"id": "e0",
"source": "n0",
"target": "n1"
},
{
"id": "e1",
"source": "n1",
"target": "n2"
},
{
"id": "e2",
"source": "n2",
"target": "n0"
}
]
}

最佳答案

dot -Txdot_json -ogrpaph.json graph.dot

https://www.graphviz.org/doc/info/output.html#a:xdot_json

关于graphviz - 如何将点图转换为 json 图?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40262441/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com