Crates.io | rs-graphs |
lib.rs | rs-graphs |
version | 0.1.2 |
source | src |
created_at | 2023-10-30 12:28:57.838316 |
updated_at | 2023-11-02 02:01:03.815152 |
description | Graph algorithms in Rust,图算法库/图数据库 |
homepage | |
repository | |
max_upload_size | |
id | 1018427 |
size | 19,265 |
Graph algorithms in Rust
Rust 实现图数据库
[dependencies]
rs-graphs = "*"
初始化一个链表
use rs_graphs::graph::{Node, ArenaList, Graph};
let mut arena_list = ArenaList::new();
let mut graph = Graph::new(&mut arena_list);
graph.add_node(name: &str, data:T) -> usize
graph.add_node_and_edge(src_name: &str, src_data: T, dst_name: &str, dst_data: T)
graph.get_node(idx: usize) -> &Node<T>
graph.get_idx_by_name(name: &str) -> Option<&usize>
graph.get_name_by_idx(idx: usize) -> &str
graph.del_node_by_idx()
,根据节点名字删除节点 graph.del_node_by_name()
,graph.del_edge_by_idx()
,graph.del_edge_by_name()
graph.clear()
graph.add_node(name: &str, data: T) -> usize
如果不存在,则创建节点。如果存在则修改其值。T
为字符串的情况
graph.save(filename)
graph.load(filename)