# GraphCalc
[](https://graphcalc.readthedocs.io/en/latest/?badge=latest)
[](https://pypi.org/project/graphcalc/)
[](https://opensource.org/licenses/MIT)
## 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:
```bash
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.solve_independent_set(G)`):
- **CBC** (recommended):
```bash
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
```python
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
```python
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_graph_properties_dataframe(function_names, graphs)
print(df)
```
## Creating Simple Graphs, Polytope Graphs, and Simple Polytope Graphs
```python
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>
Raw data
{
"_id": null,
"home_page": null,
"name": "graphcalc",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": "graph theory, networkx, graph computation",
"author": null,
"author_email": "Randy Davila <rrd6@rice.edu>",
"download_url": "https://files.pythonhosted.org/packages/44/e3/2c002714c934c9ee476189d81de02fe662156ebe22a1abf5deb06648b757/graphcalc-1.2.1.tar.gz",
"platform": null,
"description": "# GraphCalc\n\n[](https://graphcalc.readthedocs.io/en/latest/?badge=latest)\n[](https://pypi.org/project/graphcalc/)\n[](https://opensource.org/licenses/MIT)\n\n## Overview\n\n`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.\n\n## Features\n\n- **Maximum Clique**: Finds the maximum clique in a given graph.\n- **Chromatic Number**: Computes the minimum number of colors required for graph coloring.\n- **Vertex and Edge Cover**: Determines vertex and edge covers.\n- **Matching and Independence**: Calculates maximum matching and independent sets.\n- **Domination Number and its Variants**: Calculates the domination number, total domination number, and many other domination variants.\n- **Degree Sequence Invariants**: Calculates the residue, annihilaiton number, the slater number and more!\n- **Zero Forcing**: Calculates the zero forcing number, the total zero forcing number, the positive semidefinite zero forcing number, and the power domination number.\n\n## Installation\n\nTo install `graphcalc`, make sure you have Python 3.7 or higher, then install it:\n\n```bash\npip install graphcalc\n```\n\n## Linear and Integer Programming Solvers\n\nMany 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.solve_independent_set(G)`):\n\n- **CBC** (recommended):\n\n```bash\nbrew install cbc # macOS\nsudo apt install coinor-cbc # Debian/Ubuntu\n```\n\nGraphCalc will attempt to automatically detect the solver if it is installed. You can also manually specify the solver in API calls.\n\n## Example Graph Usage\n\n```python\nfrom graphcalc import (\n independence_number,\n domination_number,\n zero_forcing_number,\n)\nfrom graphcalc.generators import petersen_graph\n\n# Calculate and print the independence number of the Petersen graph.\nG = petersen_graph()\nprint(f\"Petersen graph independence number = {independence_number(G)}\")\n\n# Calculate and print the domination number of the Petersen graph.\nprint(f\"Petersen graph domination number = {domination_number(G)}\")\n\n# Calculate and print the zero forcing number of the Petersen graph.\nprint(f\"Petersen graph zero forcing number = {zero_forcing_number(G)}\")\n```\n\n## Example Polytope Usage\n\n```python\nimport graphcalc as gc\nfrom graphcalc.polytopes.generators import (\n cube_graph,\n octahedron_graph,\n dodecahedron_graph,\n tetrahedron_graph,\n icosahedron_graph,\n convex_polytopes_text_example,\n)\n\n# Generate polytope graphs (cubes, octahedra, etc.)\nG1 = cube_graph()\nG2 = octahedron_graph()\nG3 = dodecahedron_graph()\nG4 = tetrahedron_graph()\nG5 = icosahedron_graph()\nG6 = convex_polytopes_text_example(1)\nG7 = convex_polytopes_text_example(2)\n\n\n# Function names to compute\nfunction_names = [\n \"order\", # number of vertices\n \"size\", # number of edges\n \"p_vector\",\n \"independence_number\",\n \"vertex_cover_number\",\n \"maximum_degree\",\n \"average_degree\",\n \"minimum_degree\",\n \"spectral_radius\",\n \"diameter\",\n \"radius\",\n \"girth\",\n \"algebraic_connectivity\",\n \"largest_laplacian_eigenvalue\",\n \"second_largest_adjacency_eigenvalue\",\n \"smallest_adjacency_eigenvalue\",\n \"fullerene\",\n ]\n\n# Compute properties for multiple polytopes\ngraphs = [G1, G2, G3, G4, G5, G6, G7]\ndf = gc.compute_graph_properties_dataframe(function_names, graphs)\nprint(df)\n```\n\n## Creating Simple Graphs, Polytope Graphs, and Simple Polytope Graphs\n\n```python\nimport graphcalc as gc\n\n# Draw a simple graph\nG = gc.SimpleGraph(name=\"Example Graph\")\nG.add_edges_from([(0, 1), (1, 2), (2, 3)])\nG.draw()\n```\n\n### Author\n\nRandy Davila, PhD\nEmail: <rrd6@rice.edu>\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A Python package for graph computation functions",
"version": "1.2.1",
"project_urls": {
"Documentation": "https://graphcalc.readthedocs.io/en/latest/",
"PyPI": "https://pypi.org/project/graphcalc/",
"Source Code": "https://github.com/randyrdavila/graphcalc"
},
"split_keywords": [
"graph theory",
" networkx",
" graph computation"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "66365350e13c422c80883081a77b59bfbe177ad541b671270bbacefeac200f57",
"md5": "e45b7496bbfbe75ac6a60ffaff789966",
"sha256": "ae911cc3a711741687de6771fa7e2eacf06c6b7f71e2ddb8cd64796293416aa8"
},
"downloads": -1,
"filename": "graphcalc-1.2.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e45b7496bbfbe75ac6a60ffaff789966",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 41714,
"upload_time": "2025-07-28T03:32:33",
"upload_time_iso_8601": "2025-07-28T03:32:33.941472Z",
"url": "https://files.pythonhosted.org/packages/66/36/5350e13c422c80883081a77b59bfbe177ad541b671270bbacefeac200f57/graphcalc-1.2.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "44e32c002714c934c9ee476189d81de02fe662156ebe22a1abf5deb06648b757",
"md5": "9e2508c642ad192ab10a4870ccc01af7",
"sha256": "4dd659b6be76b4df72f1bba0dd58bdc9e8e229c9f8bc7e22be0e1e1bda3276b4"
},
"downloads": -1,
"filename": "graphcalc-1.2.1.tar.gz",
"has_sig": false,
"md5_digest": "9e2508c642ad192ab10a4870ccc01af7",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 42046,
"upload_time": "2025-07-28T03:32:35",
"upload_time_iso_8601": "2025-07-28T03:32:35.320965Z",
"url": "https://files.pythonhosted.org/packages/44/e3/2c002714c934c9ee476189d81de02fe662156ebe22a1abf5deb06648b757/graphcalc-1.2.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-28 03:32:35",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "randyrdavila",
"github_project": "graphcalc",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "graphcalc"
}