GraphEvo: Genetic Algorithm for Graph Optimization
GraphEvo is a powerful C++ library with Python bindings that implements genetic algorithms for graph optimization problems. It provides efficient tools for evolving and optimizing graph structures using genetic algorithms.
Features
- Genetic Algorithm Implementation: Core genetic algorithm operations including selection, crossover, and mutation
- Graph Generation: Tools for generating and evolving graph structures
- Fitness Evaluation: Customizable fitness functions for graph optimization
- High Performance: C++ implementation with Python bindings for optimal performance
Installation
From PyPI
pip install graphevo
From Source
# Clone the repository
git clone https://github.com/Js-Hwang1/GraphEvo.git
cd GraphEvo/python
# Install in development mode
pip install -e .
Requirements
- Python 3.7 or higher
- C++17 compatible compiler
- CMake 3.10 or higher
- Eigen3
- pybind11
Quick Start
import graphevo as ge
import networkx as nx
# Create a graph generator
generator = ge.GraphGenerator()
# Generate an initial population
population = generator.generate_population(
population_size=100,
num_nodes=50,
edge_probability=0.3
)
# Create a genetic algorithm instance
ga = ge.GeneticAlgorithm(
population=population,
mutation_rate=0.1,
crossover_rate=0.8,
elite_size=5
)
# Run the genetic algorithm
best_graph = ga.evolve(
generations=100,
fitness_function=lambda g: nx.density(g) # Example fitness function
)
# Access the best graph
print(f"Best graph density: {nx.density(best_graph)}")
Core Components
GraphGenerator
- Generates random graphs
- Creates initial populations
- Supports various graph generation strategies
GeneticAlgorithm
- Implements the core genetic algorithm
- Handles selection, crossover, and mutation
- Supports customizable fitness functions
GeneticOperators
- Provides mutation and crossover operations
- Customizable for different graph types
- Optimized for performance
FitnessEvaluator
- Evaluates graph fitness
- Supports custom fitness functions
- Handles multi-objective optimization
Advanced Usage
Custom Fitness Functions
def custom_fitness(graph):
# Calculate graph properties
density = nx.density(graph)
clustering = nx.average_clustering(graph)
# Combine into a single fitness score
return density * clustering
# Use in genetic algorithm
ga = ge.GeneticAlgorithm(
population=population,
fitness_function=custom_fitness
)
Custom Genetic Operators
def custom_mutation(graph):
# Implement custom mutation logic
return mutated_graph
def custom_crossover(parent1, parent2):
# Implement custom crossover logic
return child_graph
# Use custom operators
ga.set_mutation_operator(custom_mutation)
ga.set_crossover_operator(custom_crossover)
Citation
If you use GraphEvo in your research, please cite:
@software{GraphEvo,
author = {Junsung Hwang},
title = {GraphEvo: Genetic Algorithm for Graph Optimization},
year = {2025},
publisher = {GitHub},
url = {https://github.com/Js-Hwang1/GraphEvo}
}
Contact
- Author: Junsung Hwang
- Email: hwang30916@gmail.com
- GitHub: Js-Hwang1
Metadata
Release files for graphevo 0.1.0
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 |
|---|---|---|---|---|
| graphevo-0.1.0.tar.gz | 94.3 kB | Without provenance | Details for graphevo-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| graphevo-0.1.0-cp313-cp313-macosx_15_0_arm64.whl | CPython 3.13 | CPython 3.13 | macOS 15.0+ ARM64 | Details for graphevo-0.1.0-cp313-cp313-macosx_15_0_arm64.whl |
Total release size: 313.1 kB
Release files / graphevo-0.1.0.tar.gz
| Download URL | graphevo-0.1.0.tar.gz |
|---|---|
| Size | 94.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
feb2281670185f4b18a4248c7df9e7c82ccf56f7f96f53895a03dc8aa188ce92
|
|
BLAKE2b-256 checksum How to use checksums |
ab5797e7057b7699421d4c9fe38da4b09ebe054a2ccc93551d52fe908b1633c7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Release files / graphevo-0.1.0-cp313-cp313-macosx_15_0_arm64.whl
| Download URL | graphevo-0.1.0-cp313-cp313-macosx_15_0_arm64.whl |
|---|---|
| Size | 218.9 kB |
| Tags | CPython 3.13 macOS 15.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
31d40d842a6e9bff3f2e6953a545c666c921eaf399e7c7857da00281b42be84c
|
|
BLAKE2b-256 checksum How to use checksums |
f3bceef35df371509db874b4cb6c528cec6498af95a4591c2b91a29664e907af
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Security for graphevo 0.1.0
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.