#graph #parent #relationship #graph-node #node

icentral-parents-map

A Rust crate to manage parent-node relationships with features to add, set, and query parents, suitable for graph-based frameworks

1 unstable release

new 0.1.0 Apr 4, 2025

#11 in #relationship


Used in 34 crates (13 directly)

MIT/Apache

17KB
240 lines

icentral-parents-map

icentral-parents-map provides a robust data structure for managing parent-child relationships between nodes, widely applicable in domains such as graph theory, dependency tracking, and hierarchical systems.

Features

  • Node Parent Management: Add, set, and retrieve parents for nodes.
  • Clearance Functions: Remove all or specific node's parents.
  • Dynamic Structure Initialization: Flexible methods for initializing and reinitializing structures with different sizes.

Usage

Integrate this crate to efficiently manage node relationships through a rich API surface encapsulated in Rust traits.

Public Traits

  • NumParentsForNode: Retrieve the number of parents for a given node.
  • ParentsForNode: Obtain the list of parents for a node.
  • ClearParents, ClearNodeParents: Functions to clear parent linkage.
  • SetParentsForNode, SetSingleParent: Set multiple or single parents for nodes.
  • HasParent: Check if a node has a specified parent.
  • AddParent: Add a parent to a specific node.

Example

use crate::{ParentsMap, NodeId};

fn main() {
    let mut pm = ParentsMap::new(5, "example");
    let node = NodeId(1);
    let parent = NodeId(2);
    pm.set_single_parent(node, parent);
    assert!(pm.has_parent(node, parent));
}

Important Notes

  • Utilize delegate_to_parents macro for efficient trait delegation.
  • Suitable for graph-based implementations with nodes indexed using NodeId.

License

This project is licensed under the provisions of both MIT and Apache 2.0 licenses.


This README.md file was generated by an AI model and may not be 100% accurate, though it aims to provide high utility and comprehensible content.

This crate is in the process of being translated from c++ to rust. Currently, it still needs exhaustive testing. It is likely there currently exist many glitches which need to be fixed before proper usage. This crate is based on the original icentral program developed by Fuad Jamor. Please see the following repository for details: https://github.com/fjamour/icentral.

For progress updates, see the workspacer rust project.

Dependencies

~16–25MB
~389K SLoC