7 个版本

0.2.2 2021年1月22日
0.2.1 2021年1月21日
0.1.4 2021年1月21日

#2398数据结构

37 每月下载量
用于 try_encoding_from

MIT/Apache

33KB
528 代码行

二叉树图 (btree_graph)

CodeBuild Version badge Docs badge

此库通过两个二叉树映射(BTreeMap)实现了图(抽象数据结构)的简化实现。这种实现通常被称为邻接表。

此实现的主要目标是保持最小化,并符合 Rust 语言的风格。当使用默认功能编译时,只有 alloc 包是依赖项,并且不是可选的。正如人们所假设的,alloc 是必需的,因为实现依赖于 BTreeMap(以及 BTreeSet 包装器)。

示例

use btree_graph::BTreeGraph;

fn main() {
    let mut graph: BTreeGraph<String, String> = BTreeGraph::new();
    // Add nodes.
    graph.add_vertex(String::from("Tarzan"));
    graph.add_vertex(String::from("Jane"));
    // Add a relationship.
    graph.add_edge(String::from("Tarzan"), String::from("Jane"), String::from("Loves"));
    
    // Assert relationship now exists.
    assert!(graph.adjacdent(String::from("Tarzan"), String::from("Jane")));
}

用法

将以下内容添加到您的 Cargo.toml 文件中

[dependencies]
btree_graph = "0.2.2"

API

请参阅 API 以获取可用方法的完整列表。

许可证

此作品根据 MIT 或 Apache-2.0 许可证双重授权。

依赖项

~0–520KB
~11K SLoC