# GraphCalc
[](https://graphcalc.readthedocs.io/en/latest/?badge=latest)
## 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
```
## 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
Raw data
{
"_id": null,
"home_page": "https://github.com/randydavila/graphcalc",
"name": "graphcalc",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": "graph theory, networkx, graph computation",
"author": "Randy Davila",
"author_email": "rrd6@rice.edu",
"download_url": "https://files.pythonhosted.org/packages/66/1c/e198a8eeec7e4a4e43b3a6bd5d7b63aa9eb35ad8aab78f140a28518e14fb/graphcalc-0.1.20.tar.gz",
"platform": null,
"description": "# GraphCalc\n[](https://graphcalc.readthedocs.io/en/latest/?badge=latest)\n\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\n## Example Graph Usage\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```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```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\n### Author\nRandy Davila, PhD\n\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A Python package for graph computation functions",
"version": "0.1.20",
"project_urls": {
"Documentation": "https://graphcalc.readthedocs.io/en/latest/",
"Homepage": "https://github.com/randydavila/graphcalc",
"PyPI": "https://pypi.org/project/graphcalc/",
"Source Code": "https://github.com/randydavila/graphcalc"
},
"split_keywords": [
"graph theory",
" networkx",
" graph computation"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "72d8864cdf42090fa446f36f0c6e347ebce7b49b0cd7a149bd4fb885c46d82bb",
"md5": "67638b5215058d75af3bfe4b62f4a208",
"sha256": "9d40d59294848d95ed2cfa9b6d45997b07687537cb8fb0ee6a94b561f8f915a2"
},
"downloads": -1,
"filename": "graphcalc-0.1.20-py3-none-any.whl",
"has_sig": false,
"md5_digest": "67638b5215058d75af3bfe4b62f4a208",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 83288,
"upload_time": "2025-02-07T18:03:21",
"upload_time_iso_8601": "2025-02-07T18:03:21.151990Z",
"url": "https://files.pythonhosted.org/packages/72/d8/864cdf42090fa446f36f0c6e347ebce7b49b0cd7a149bd4fb885c46d82bb/graphcalc-0.1.20-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "661ce198a8eeec7e4a4e43b3a6bd5d7b63aa9eb35ad8aab78f140a28518e14fb",
"md5": "703440235013e68f86b00742252caccc",
"sha256": "939f010da544de89d13b634586dca0591bdf683ca5d181cc234f56ad8358bcb1"
},
"downloads": -1,
"filename": "graphcalc-0.1.20.tar.gz",
"has_sig": false,
"md5_digest": "703440235013e68f86b00742252caccc",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 38545,
"upload_time": "2025-02-07T18:03:23",
"upload_time_iso_8601": "2025-02-07T18:03:23.953674Z",
"url": "https://files.pythonhosted.org/packages/66/1c/e198a8eeec7e4a4e43b3a6bd5d7b63aa9eb35ad8aab78f140a28518e14fb/graphcalc-0.1.20.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-02-07 18:03:23",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "randydavila",
"github_project": "graphcalc",
"github_not_found": true,
"lcname": "graphcalc"
}