A high-performance Python library for generating and manipulating cographs, with canonical structure parsing and graph6 encoding.
Project description
CographGenerator
CographGenerator is a high-performance Python library for generating and manipulating cographs, with canonical structure parsing and Graph6 encoding. The library focuses on generating all cographs of a given size and exporting them in graph6 (g6) format, suitable for graph-theoretical applications and combinatorial research.
Installation
You can install the library via pip:
pip install cographgenerator
Note: This library depends on NumPy, which will be installed automatically.
Quick Start
The main function exposed by the library is generate_cographs_final_g6, which generates all cographs for a given number of vertices and saves them to a file in graph6 format.
from cographgenerator import generate_cographs_final_g6
Generate all cographs with 3 vertices
output_file = generate_cographs_final_g6(node_count=3, output_filename="cographs_3.g6")
print(f"Cographs generated and saved in: {output_file}")
This will create a file named cographs_3.g6 containing all canonical cographs with 3 vertices encoded in graph6 format.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| node_count | int | — | Number of vertices in the cographs to generate. |
| output_filename | str | "cographs_g6.txt" | Destination filename for the final graph6 output. |
| batch_size | int | 50000 | Number of structures to convert per batch in phase 2. |
| num_processes | int | 8 | Number of worker processes used during graph6 conversion. |
How it Works
- Generate canonical cotree structures: Recursively constructs all canonical string representations of cographs of a given size.
- Convert structures to adjacency matrices: Each canonical structure is converted into a square adjacency matrix.
- Encode in Graph6 format: The adjacency matrices are transformed into compact graph6 strings and written to the output file.
The library internally optimizes memory usage by streaming the structures and processing them in batches, making it suitable for large graphs.
License
This project is licensed under the MIT License.
References
- Graph6 Format: https://users.cecs.anu.edu.au/~bdm/nauty/manual.pdf
- Cographs on Wikipedia: https://en.wikipedia.org/wiki/Cograph
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cograph_generator-0.1.2.tar.gz.
File metadata
- Download URL: cograph_generator-0.1.2.tar.gz
- Upload date:
- Size: 12.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
41627634a742f12e16b3fda363a0f9428bf714ce9d5ae77fa5812b9c8d7ed3dc
|
|
| MD5 |
56cb844a006910df2445e41ec51741fe
|
|
| BLAKE2b-256 |
cb35cd403022f19e50dd313db32796868d75e23d47988c8443c3677fa931ee3a
|
File details
Details for the file cograph_generator-0.1.2-py3-none-any.whl.
File metadata
- Download URL: cograph_generator-0.1.2-py3-none-any.whl
- Upload date:
- Size: 12.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4faa25aecaef6efda2bde6ca85b2468317dc3351f9b4686367a98a3d2f15e1b7
|
|
| MD5 |
ec150969527d6ce631bfd0d5d1aea506
|
|
| BLAKE2b-256 |
51f4bb9bb38d7a27dca22feb43afc0731d1494b05fc7fd4d10a07b71869ec0cd
|