pstree 0.1.1

Segment Tree of Placements
Documentation
  • Coverage
  • 0%
    0 out of 11 items documented0 out of 4 items with examples
  • Size
  • Source code size: 35.99 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.95 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 10s Average build duration of successful builds.
  • all releases: 10s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • stavegan

Segment Tree of Placements

I consent to the transfer of this crate to the first person who asks help@crates.io for it.

The pstree crate allows you to create an n to k segment tree of placements based on a key in the range 0..=n. This key will be used as the root and leaves of the tree. So other vertices will be taken in the ranges 0..key and key + 1..=n.

The structure is designed to quickly respond to queries to change a vertex or edge in a weighted directed graph that allows edges of negative weight.

Example

use pstree::PSTree;

fn main() {
    let pstree = PSTree::new(3, 2, 0, 0);
    let _shortest = pstree.update_vertex(1, 1);
    let _shortest = pstree.update_edge(0, 1, 2);
}

The PSTree::new(3, 2, 0, 0) creates a 3 by 2 tree of placements based on key 0 with initial value 0:

0
├── 1
│   ├── 2
│   │   └── 0
│   └── 3
│       └── 0
├── 2
│   ├── 1
│   │   └── 0
│   └── 3
│       └── 0
└── 3
    ├── 1
    │   └── 0
    └── 2
        └── 0

The pstree.update_vertex(1, 1) updates vertex 1 with value 1, so the distances will be recalculated, returning the shortest distance from key of length k:

0
├── 1
│   '-- 2
│   '   '-- 0
│   '-- 3
│       '-- 0
├── 2
│   ├── 1
│   │   '-- 0
│   └── 3
│       └── 0
└── 3
    ├── 1
    │   '-- 0
    └── 2
        └── 0

The pstree.update_edge(0, 1, 2) updates edge from 0 to 1 with value 2, so the distances will be recalculated, returning the shortest distance from key of length k:

0
'-- 1
│   '-- 2
│   '   '-- 0
│   '-- 3
│       '-- 0
├── 2
│   ├── 1
│   │   └── 0
│   └── 3
│       └── 0
└── 3
    ├── 1
    │   └── 0
    └── 2
        └── 0

Usage

[dependencies]
pstree = "0.1"

License

Licensed under either of

at your option.