A Python package for graph computation functions
Project description
GraphCalc
Overview
graphcalc is a Python package for performing a variety of graph computations, including maximum clique detection, chromatic number calculation, and vertex cover identification. It is built on top of networkx and provides efficient implementations of fundamental graph theory algorithms.
Features
- Maximum Clique: Finds the maximum clique in a given graph.
- Chromatic Number: Computes the minimum number of colors required for graph coloring.
- Vertex and Edge Cover: Determines vertex and edge covers.
- Matching and Independence: Calculates maximum matching and independent sets.
- Domination Number and its Variants: Calculates the domination number, total domination number, and many other domination variants.
- Degree Sequence Invariants: Calculates the residue, annihilaiton number, the slater number and more!
- Zero Forcing: Calculates the zero forcing number, the total zero forcing number, the positive semidefinite zero forcing number, and the power domination number.
Installation
To install graphcalc, make sure you have Python 3.7 or higher, then install it:
pip install graphcalc
Linear and Integer Programming Solvers
Many of the NP-hard graph invariant computations of GraphCalc depend on third-party solvers.At least one of the following is required if you intend to use solver-based functions (e.g., gc.maximum_independent_set(G)):
- CBC (recommended):
brew install cbc # macOS
sudo apt install coinor-cbc # Debian/Ubuntu
GraphCalc will attempt to automatically detect the solver if it is installed. You can also manually specify the solver in API calls.
Example Graph Usage
from graphcalc import (
independence_number,
domination_number,
zero_forcing_number,
)
from graphcalc.generators import petersen_graph
# Calculate and print the independence number of the Petersen graph.
G = petersen_graph()
print(f"Petersen graph independence number = {independence_number(G)}")
# Calculate and print the domination number of the Petersen graph.
print(f"Petersen graph domination number = {domination_number(G)}")
# Calculate and print the zero forcing number of the Petersen graph.
print(f"Petersen graph zero forcing number = {zero_forcing_number(G)}")
Example Polytope Usage
import graphcalc as gc
from graphcalc.polytopes.generators import (
cube_graph,
octahedron_graph,
dodecahedron_graph,
tetrahedron_graph,
icosahedron_graph,
convex_polytopes_text_example,
)
# Generate polytope graphs (cubes, octahedra, etc.)
G1 = cube_graph()
G2 = octahedron_graph()
G3 = dodecahedron_graph()
G4 = tetrahedron_graph()
G5 = icosahedron_graph()
G6 = convex_polytopes_text_example(1)
G7 = convex_polytopes_text_example(2)
# Function names to compute
function_names = [
"order", # number of vertices
"size", # number of edges
"p_vector",
"independence_number",
"vertex_cover_number",
"maximum_degree",
"average_degree",
"minimum_degree",
"spectral_radius",
"diameter",
"radius",
"girth",
"algebraic_connectivity",
"largest_laplacian_eigenvalue",
"second_largest_adjacency_eigenvalue",
"smallest_adjacency_eigenvalue",
"fullerene",
]
# Compute properties for multiple polytopes
graphs = [G1, G2, G3, G4, G5, G6, G7]
df = gc.compute_knowledge_table(function_names, graphs)
Creating Simple Graphs, Polytope Graphs, and Simple Polytope Graphs
import graphcalc as gc
# Draw a simple graph
G = gc.SimpleGraph(name="Example Graph")
G.add_edges_from([(0, 1), (1, 2), (2, 3)])
G.draw()
Author
Randy Davila, PhD Email: rrd6@rice.edu
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 graphcalc-1.2.4.tar.gz.
File metadata
- Download URL: graphcalc-1.2.4.tar.gz
- Upload date:
- Size: 43.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b50bfa10d7ce184d418723fe6fe1ed2540865e6042935394419b85947af9d8e
|
|
| MD5 |
f2d29657341da996c3e710b6d79495d7
|
|
| BLAKE2b-256 |
301a4fba29da51fff2feef3a756699251b686ee991fdc79d12dc82589915c326
|
Provenance
The following attestation bundles were made for graphcalc-1.2.4.tar.gz:
Publisher:
release.yml on RandyRDavila/GraphCalc
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
graphcalc-1.2.4.tar.gz -
Subject digest:
6b50bfa10d7ce184d418723fe6fe1ed2540865e6042935394419b85947af9d8e - Sigstore transparency entry: 409580755
- Sigstore integration time:
-
Permalink:
RandyRDavila/GraphCalc@3c82567e288c73eaf2f8de52838ce5dada540be1 -
Branch / Tag:
refs/tags/v1.2.4 - Owner: https://github.com/RandyRDavila
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@3c82567e288c73eaf2f8de52838ce5dada540be1 -
Trigger Event:
push
-
Statement type:
File details
Details for the file graphcalc-1.2.4-py3-none-any.whl.
File metadata
- Download URL: graphcalc-1.2.4-py3-none-any.whl
- Upload date:
- Size: 43.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f4b5353816bacbb5a3125b72cca93c077155417bee9edb06c4a814cfbecc31b5
|
|
| MD5 |
36fed2a427d704277f4881c9cf948a9d
|
|
| BLAKE2b-256 |
788c2353eaea6d115cda85dca8beedafe334dee81f7df18c3aa446becf0bc177
|
Provenance
The following attestation bundles were made for graphcalc-1.2.4-py3-none-any.whl:
Publisher:
release.yml on RandyRDavila/GraphCalc
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
graphcalc-1.2.4-py3-none-any.whl -
Subject digest:
f4b5353816bacbb5a3125b72cca93c077155417bee9edb06c4a814cfbecc31b5 - Sigstore transparency entry: 409580756
- Sigstore integration time:
-
Permalink:
RandyRDavila/GraphCalc@3c82567e288c73eaf2f8de52838ce5dada540be1 -
Branch / Tag:
refs/tags/v1.2.4 - Owner: https://github.com/RandyRDavila
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@3c82567e288c73eaf2f8de52838ce5dada540be1 -
Trigger Event:
push
-
Statement type: