4 个版本

0.1.3 2022年4月23日
0.1.2 2020年12月29日
0.1.1 2020年6月27日
0.1.0 2020年6月27日

#124 in 可视化

Download history · Rust 包仓库 2345/week @ 2024-03-14 · Rust 包仓库 2874/week @ 2024-03-21 · Rust 包仓库 3202/week @ 2024-03-28 · Rust 包仓库 2175/week @ 2024-04-04 · Rust 包仓库 2065/week @ 2024-04-11 · Rust 包仓库 2250/week @ 2024-04-18 · Rust 包仓库 2693/week @ 2024-04-25 · Rust 包仓库 2586/week @ 2024-05-02 · Rust 包仓库 2827/week @ 2024-05-09 · Rust 包仓库 2482/week @ 2024-05-16 · Rust 包仓库 2381/week @ 2024-05-23 · Rust 包仓库 3391/week @ 2024-05-30 · Rust 包仓库 2295/week @ 2024-06-06 · Rust 包仓库 2596/week @ 2024-06-13 · Rust 包仓库 3295/week @ 2024-06-20 · Rust 包仓库 2126/week @ 2024-06-27 · Rust 包仓库

10,778 每月下载量
用于 13 个 crate (6 个直接使用)

MIT 许可证

100KB
3K SLoC

tabbycat

关于

这个 crate 用于使用 rust 中定义的类型生成 dot 图。整个 crate 的实现遵循 graphviz 网站 列出的 dot 语言规范。

属性

有一个可选的功能 attributes,它实现了 dot 语言属性列表的一个子集。dot 语言的属性列表。启用此功能后,您可以编写类似的内容

use tabbycat::attributes::*;
use tabbycat::AttrList;
let attrlist =  AttrList::new()
    .add_pair(fontsize(12.0))
    .add_pair(label("test"))
    .new_bracket()
    .add_pair(fillcolor(Color::Blue))
    .add_pair(arrowhead(ArrowShape::Orinv));
assert_eq!("[fontsize=12;label=\"test\";][fillcolor=blue;arrowhead=orinv;]", attrlist.to_string())

示例

use tabbycat::attributes::*;
use tabbycat::{AttrList, GraphBuilder, GraphType, Identity, StmtList, Edge, SubGraph};
let graph = GraphBuilder::default()
    .graph_type(GraphType::DiGraph)
    .strict(false)
    .id(Identity::id("G").unwrap())
    .stmts(StmtList::new()
        .add_node(Identity::id("A").unwrap(), None, Some(AttrList::new().add_pair(color(Color::Red))))
        .add_edge(Edge::head_node(Identity::id("B").unwrap(), None)
            .arrow_to_node(Identity::id("C").unwrap(), None)
            .add_attrpair(arrowhead(ArrowShape::Diamond)))
        .add_subgraph(SubGraph::subgraph(Some(Identity::id("D").unwrap()),
            StmtList::new()
                .add_edge(Edge::head_node(Identity::id("E").unwrap(), None)
                    .arrow_to_node(Identity::id("F").unwrap(), None)))))
    .build()
    .unwrap();
println!("{}", graph);

这将生成类似以下的输出

digraph G{A[color=red;];B->C[arrowhead=diamond;];subgraph D{E->F;};}

依赖

~5.5MB
~101K SLoC