Struct rose_tree::RoseTree [] [src]

pub struct RoseTree<N, Ix: IndexType = DefIndex> { /* fields omitted */ }

An indexable tree data structure with a variable and unbounded number of branches per node.

Also known as a multi-way tree.

See the wikipedia article on the "Rose tree" data structure.

Note: The following documentation is adapted from petgraph's Graph documentation.

RoseTree is parameterized over the node weight N and Ix which is the index type used.

A wrapper around petgraph's Graph data structure with a refined API specifically targeted towards use as a RoseTree.

NodeIndex is a type that acts as a reference to nodes, but these are only stable across certain operations. Removing nodes may shift other indices. Adding kids to the RoseTree keeps all indices stable, but removing a node will force the last node to shift its index to take its place.

The fact that the node indices in the RoseTree are numbered in a compact interval from 0 to n-1 simplifies some graph algorithms.

The Ix parameter is u32 by default. The goal is that you can ignore this parameter completely unless you need a very large RoseTree -- then you can use usize.

The RoseTree also offers methods for accessing the underlying Graph, which can be useful for taking advantage of petgraph's various graph-related algorithms.

Methods

impl<N, Ix> RoseTree<N, Ix> where
    Ix: IndexType
[src]

Create a new RoseTree along with some root node. Returns both the RoseTree and an index into the root node in a tuple.

Create a new RoseTree with estimated capacity and some root node. Returns both the RoseTree and an index into the root node in a tuple.

The total number of nodes in the RoseTree.

Borrow the RoseTree's underlying PetGraph<N, Ix>. All existing NodeIndexs may be used to index into this graph the same way they may be used to index into the RoseTree.

Take ownership of the RoseTree and return the internal PetGraph. All existing NodeIndexs may be used to index into this graph the same way they may be used to index into the RoseTree.

Add a child node to the node at the given NodeIndex. Returns an index into the child's position within the tree.

Computes in O(1) time.

Panics if the given parent node doesn't exist.

Panics if the Graph is at the maximum number of edges for its index.

Borrow the weight from the node at the given index.

Mutably borrow the weight from the node at the given index.

Index the RoseTree by two node indices.

Panics if the indices are equal or if they are out of bounds.

Remove all nodes in the RoseTree except for the root.

Removes and returns the node at the given index.

The parent of node will become the new parent for all of its children.

The root node cannot be removed. If its index is given, None will be returned.

Note: this method may shift other node indices, invalidating previously returned indices!

Removes the node at the given index along with all their children, returning them as a new RoseTree.

If there was no node at the given index, None will be returned.

An index to the parent of the node at the given index if there is one.

An iterator over the given child's parent, that parent's parent and so forth.

The returned iterator yields NodeIndex<Ix>s.

An iterator over all nodes that are children to the node at the given index.

The returned iterator yields NodeIndex<Ix>s.

A "walker" object that may be used to step through the children of the given parent node.

Unlike the Children type, WalkChildren does not borrow the RoseTree.

An iterator over all nodes that are siblings to the node at the given index.

The returned iterator yields NodeIndex<Ix>s.

A "walker" object that may be used to step through the siblings of the given child node.

Unlike the Siblings type, WalkSiblings does not borrow the RoseTree.

Trait Implementations

impl<N: Clone, Ix: Clone + IndexType> Clone for RoseTree<N, Ix>
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<N: Debug, Ix: Debug + IndexType> Debug for RoseTree<N, Ix>
[src]

Formats the value using the given formatter.

impl<N, Ix> Index<NodeIndex<Ix>> for RoseTree<N, Ix> where
    Ix: IndexType
[src]

The returned type after indexing

The method for the indexing (container[index]) operation

impl<N, Ix> IndexMut<NodeIndex<Ix>> for RoseTree<N, Ix> where
    Ix: IndexType
[src]

The method for the mutable indexing (container[index]) operation