Skip to main content

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

  1. Generate canonical cotree structures: Recursively constructs all canonical string representations of cographs of a given size.
  2. Convert structures to adjacency matrices: Each canonical structure is converted into a square adjacency matrix.
  3. 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cograph_generator-0.1.0.tar.gz (12.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cograph_generator-0.1.0-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file cograph_generator-0.1.0.tar.gz.

File metadata

  • Download URL: cograph_generator-0.1.0.tar.gz
  • Upload date:
  • Size: 12.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for cograph_generator-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e839fc4d5adcc753bbaa510911d07851ed3943b74bec31c880be1eff1b48188a
MD5 0efec2770a135e202097ff13c596f77b
BLAKE2b-256 91336c2c765d90f13bb84af447086bc56da17737bda2db8be323f9dfe21c3aa3

See more details on using hashes here.

File details

Details for the file cograph_generator-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for cograph_generator-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e0bd61360de7de6ef0aba102461409853b3a2c9e036ef0923946d9d621058325
MD5 6a5fb9c9b0ce7edb3df26901e1e2c793
BLAKE2b-256 a62dae4212078908132637ae0d69313d89e35bd323f7208cd3c2fb6abc17c875

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page