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.1.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.1-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: cograph_generator-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 a37a5222225356ee8184ef937cf33a379cb05697fa4669b48236ccd9803ce903
MD5 1342bbaaae90d4a88b1565b43b8c8f25
BLAKE2b-256 23a83944950b3be6dfde0549c7cb73717213e470a88a9cd218a9a58b71eb9f88

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cograph_generator-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 76458c36bb28bcc8fad1df6fc37ca03ee10be61dc3cf162ea651232e43e3b448
MD5 acef0dd65c3cdfb30b09a7ec696438eb
BLAKE2b-256 c31ad625079a9bd65e4787e14e89541decbfebbb1d24202213f1d2fa1483e418

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