Skip to main content

A Python package for graph computation functions

Project description

GraphCalc

Documentation Status

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

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_graph_properties_dataframe(function_names, graphs)
print(df)

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

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

graphcalc-1.0.4.tar.gz (39.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

graphcalc-1.0.4-py3-none-any.whl (84.0 kB view details)

Uploaded Python 3

File details

Details for the file graphcalc-1.0.4.tar.gz.

File metadata

  • Download URL: graphcalc-1.0.4.tar.gz
  • Upload date:
  • Size: 39.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.6

File hashes

Hashes for graphcalc-1.0.4.tar.gz
Algorithm Hash digest
SHA256 d617ec7d67db33d35545a130a60d79e8f4638e6409d414445b3b6cabcba6f041
MD5 3c1bdef44c1da9517eb9508e892c88b3
BLAKE2b-256 804c7223fb6a524e26281546b3c2cc0c1b0dd25dc59c848ad0799d809844f8b8

See more details on using hashes here.

File details

Details for the file graphcalc-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: graphcalc-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 84.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.6

File hashes

Hashes for graphcalc-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 ad03644800dbf2887cec7cd425063fabf2055376bf1fc938931d2b239b26dfd6
MD5 3f492bca3155de107c0b9e0eecd31829
BLAKE2b-256 f3ac7c8aa31d0f5505f7198102a408089efe25db57453abcf05f093dee5c8c8d

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