semvec/pypi-packages huggingface dataset:
disjoint-set-struct 0.0.1
Implementation of disjoint set data structure (aka union-find data structure)
Requires Python: >=3.8

# Disjoint Set (Union-Find) Data Structure

This repository contains a Python implementation of the **Disjoint Set** (also known as **Union-Find**) data structure. The implementation includes optimizations such as **path compression** and **union by rank** to ensure efficient operations.

## Features
- **Find**: Determine the root of the set containing a given element.
- **Union**: Merge two sets into one.
- **Connected**: Check if two elements are in the same set.
- **Path Compression**: Flattens the tree during `find` operations for faster future queries.
- **Union by Rank**: Keeps the tree balanced by attaching smaller trees to larger ones.

## Code Overview

### `DisjointSet` Class

#### Attributes
- **`parent`**: A list where each element points to its parent in the set.
- **`rank`**: A list representing the rank (approximate depth) of each set.

#### Methods
- **`__init__(size: int)`**: Initializes the disjoint-set with `size` elements.
- **`find(x: int) -> int`**: Finds the root of the set containing `x` with path compression.
- **`union(x: int, y: int)`**: Merges the sets containing `x` and `y` using union by rank.
- **`connected(x: int, y: int) -> bool`**: Checks if `x` and `y` are in the same set.

### Example Usage

```python
# Create a disjoint-set with 10 elements
ds = DisjointSet(10)

# Perform some union operations
ds.union(1, 2)
ds.union(3, 4)
ds.union(1, 3)

# Check if elements are connected
print(ds.connected(1, 4))  # Output: True
print(ds.connected(1, 5))  # Output: False
pygradflow 0.5.24
PyGradFlow is a simple implementation of the sequential homotopy method to be used to solve general nonlinear programs.
Requires Python: <4.0,>=3.10

[![PyPI version](https://badge.fury.io/py/pygradflow.svg)](https://badge.fury.io/py/pygradflow)
[![Documentation Status](https://readthedocs.org/projects/pygradflow/badge/?version=latest)](https://pygradflow.readthedocs.io/en/latest/?badge=latest)

# PyGradFlow

PyGradFlow is a simple implementation of the sequential homotopy method to
be used to solve general nonlinear programs.

To solve a nonlinear problem, subclass the `Problem` class, implementing
its abstract methods, pass a problem instance to a `Solver`, and call
its `solve()` method.

Note: This code is for research purposes, not productive use.


## References

- Potschka, A., Bock, H.G. A sequential homotopy method for mathematical programming problems. Math. Program. 187, 459–486 (2021). https://doi.org/10.1007/s10107-020-01488-z
- Pearson, John W., and Andreas Potschka. "A preconditioned inexact active-set method for large-scale nonlinear optimal control problems." arXiv preprint arXiv:2112.05020 (2021).