Skip to main content

Convert mathematical equations into graph structures for visualization

Project description

numgraph

PyPI version Python 3.8+

A Python library that converts mathematical equations into graph/network structures for visualization and analysis.

What is numgraph?

numgraph turns mathematical relationships into nodes and edges, then visualizes them as interactive graphs. This helps users understand how variables and operations interact.

Use cases:

  • Students learning algebra and calculus
  • Data scientists analyzing feature dependencies
  • Researchers visualizing mathematical formulas

Quick Start

Installation

Install from PyPI:

pip install numgraph-equation

Or install from source:

git clone https://github.com/Ayush-07-Mishra/numgraph.git
cd numgraph
pip install -e .

Basic Usage

from numgraph import make_graph

# Parse and visualize an equation
make_graph("x**2 + y**2 = 25", visualize=True)

# Create a function graph
make_graph("y = x**2 - 4*x + 3", func_range=(-10, 10), visualize=True)

Features

  • Parse mathematical equations using SymPy
  • Build graph structures with NetworkX
  • Interactive HTML visualizations with PyVis
  • Static plots with Matplotlib
  • Export to GraphML and GEXF formats
  • Function plotting with custom ranges

Examples

Circle Equation

from numgraph import make_graph

# Visualize the circle equation
make_graph("x**2 + y**2 = 25", visualize=True, save_path="circle.html")

Quadratic Function

from numgraph import make_graph

# Plot a parabola
make_graph("y = x**2 - 4*x + 3", func_range=(-2, 6), visualize=True)

Custom Graph Analysis

from numgraph.parser import EquationParser
from numgraph.graph_builder import GraphBuilder
from numgraph.visualizer import Visualizer

# Parse equation
parser = EquationParser("x**2 + 2*x*y + y**2 = 16")
nodes, edges = parser.parse()

# Build graph
builder = GraphBuilder(nodes, edges)
graph = builder.build()

# Visualize
viz = Visualizer(graph)
viz.show_interactive()  # Interactive HTML visualization
viz.show_static()       # Static matplotlib plot

API Reference

make_graph(equation, visualize=False, func_range=None, save_path=None)

Main function to create and optionally visualize equation graphs.

Parameters:

  • equation (str): Mathematical equation or function
  • visualize (bool): Whether to show visualization
  • func_range (tuple): Range for function evaluation (min, max)
  • save_path (str): Path to save interactive HTML visualization

Returns:

  • networkx.Graph: Graph representation of the equation

Project Structure

numgraph/
├── numgraph/
│   ├── __init__.py         # Main API
│   ├── parser.py           # Equation parsing
│   ├── graph_builder.py    # Graph creation
│   ├── visualizer.py       # Visualization
│   └── dataset.py          # Dataset utilities
├── examples/
│   ├── circle_equation.py
│   ├── quadratic_function.py
│   └── custom_analysis.py
├── tests/
│   ├── test_parser.py
│   ├── test_graph_builder.py
│   └── test_visualizer.py
├── setup.py
├── README.md
└── requirements.txt

Testing

# Run all tests
python -m pytest tests/

# Run specific test
python -m pytest tests/test_parser.py -v

Dependencies

  • sympy - Symbolic mathematics and parsing
  • networkx - Graph creation and analysis
  • pyvis - Interactive network visualization
  • matplotlib - Static plotting
  • numpy - Numerical computations

Contributing

Contributions are welcome! Please read CONTRIBUTING.md for details.

Contact

For questions or support: luckymishra312004@gmail.com

For Students

  • Visualize how equations are structured
  • Understand operator precedence
  • See variable relationships clearly

For Educators

Contact

For questions or support: luckymishra312004@gmail.com

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

numgraph_equation-0.1.3.tar.gz (15.7 kB view details)

Uploaded Source

Built Distribution

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

numgraph_equation-0.1.3-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file numgraph_equation-0.1.3.tar.gz.

File metadata

  • Download URL: numgraph_equation-0.1.3.tar.gz
  • Upload date:
  • Size: 15.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for numgraph_equation-0.1.3.tar.gz
Algorithm Hash digest
SHA256 9a7c3aa614b61f12b633a1c8b4a46d83d2a501c2a4e06b5c4d71375a6e481eb0
MD5 ec057c82d1ad93dd9fdee8385c51f448
BLAKE2b-256 5772500ef0d37639b7322a63e3986d08d9d62aaf0efe00169af2d7084cfcd754

See more details on using hashes here.

File details

Details for the file numgraph_equation-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for numgraph_equation-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 655c1ecea78531c6b2584b1f5865b6d48723d2496c77566e1e37fe2d43795c23
MD5 b1a2289720bdce65f1a6b65f27033648
BLAKE2b-256 e391c6859d1771e234f53588c242df4014ee6b7b68fc2f855201bb8f0f885337

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