KBBQGraph - Barebones and Quick for k-partite graphs
This is a WIP for a memory-efficient replacement for NetworkX for a specific application.
I work with k-partite graphs when matching datasets, where each dataset is a partite. Most immediately, I need to handle 100s of partites each with 10,000's of nodes, and ~5,000 directed edges connecting each partite set. This quickly saturates NetworkX.
I also need efficient indexing based on partite number and feature number -- this is not offered by any other graphing library.
Someday, I would like to add some very specific homegrown k-partite clustering algorithms. These also assume one-to-one constraints when compressed to undirected, i.e. at most a node u from partite i can only be connected to one node from partite j.
License - Free to distribute and use as long as credit to the developers is given. Also, if you make something better, please tell me.
In addition to the basic usage below, check out compress, weakly_connected_components and find_cliques.
import networkx as nx
from kbbqgraph import KBBQGraph
# ------------------------------------------------------------
# Create a new graph
# ------------------------------------------------------------
g = KBBQGraph(isDiGraph=0, preAllocate=10, name="example")
# ------------------------------------------------------------
# Add nodes
# ------------------------------------------------------------
# Add nodes to “dataset/partite 0”
g.add_nodes(0, [0, 1, 2])
# Add nodes to “dataset/partite 1”
g.add_nodes(1, [0, 1])
# ------------------------------------------------------------
# Add edges (batched)
# ------------------------------------------------------------
# Each node is a (dataset, id) tuple, i.e. (partite, local_index)
source_nodes = [
(0, 0), # node 0 in dataset 0
(0, 2), # node 2 in dataset 0
]
target_nodes = [
(1, 1), # node 1 in dataset 1
(1, 0), # node 0 in dataset 1
]
weights = [1.0, 0.5] # optional; can also pass None
g.add_edges(
source_nodes=source_nodes,
target_nodes=target_nodes,
weights=weights,
check_duplicates=True,
)
print("Nodes:", g.num_nodes)
print("Edges:", g.num_edges)
# ------------------------------------------------------------
# Convert to NetworkX
# ------------------------------------------------------------
nx_graph = g.to_networkx()
print("NetworkX edges (u, v, data):")
for u, v, data in nx_graph.edges(data=True):
print(u, "→", v, "weight=", data.get("weight"))
Metadata
Release files for kbbqgraph 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| kbbqgraph-0.1.1.tar.gz | 152.6 kB | Without provenance | Details for kbbqgraph-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| kbbqgraph-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for kbbqgraph-0.1.1-py3-none-any.whl |
Total release size: 304.7 kB
Release files / kbbqgraph-0.1.1.tar.gz
| Download URL | kbbqgraph-0.1.1.tar.gz |
|---|---|
| Size | 152.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c0bffcda782b5a916861d468bec8b56607387fe8517bc53b7a030c6a6dfcb4e4
|
|
BLAKE2b-256 checksum How to use checksums |
a725b1ac766fba44b46a0cc342de6557a9e40a688d54e27240538f46c2ad75a3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.12
|
Release files / kbbqgraph-0.1.1-py3-none-any.whl
| Download URL | kbbqgraph-0.1.1-py3-none-any.whl |
|---|---|
| Size | 152.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ae2fbd64cbe8a35e7c1028192e88c465237b0cb9ced713cec8aff2042e6a8029
|
|
BLAKE2b-256 checksum How to use checksums |
9ecb8464e5c069778da4b6f4c40308ff0e0a5dbd104e2f77f615ce2eec2e0803
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.12
|
Security for kbbqgraph 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.