Convert mathematical equations into graph structures for visualization
Project description
numgraph ๐ขโก๏ธ๐
A Python library that converts mathematical equations, functions, or datasets into graph/network structures for visualization and analysis.
๐ฏ What is numgraph?
numgraph turns mathematical relationships into nodes and edges, then visualizes them. This helps users see how variables and operations interact โ perfect for:
- ๐ Students learning algebra/calculus
- ๐ฌ Data scientists analyzing feature dependencies
- ๐งช Researchers visualizing formulas or constraints
๐ Quick Start
Installation
Install from PyPI (once published):
pip install numgraph
Or install from source:
git clone https://github.com/ayushmishra/numgraph.git
cd numgraph
pip install -e .
For development:
pip install -e ".[dev]"
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
โ Phase 1: Core Functionality (MVP)
- Parse mathematical equations using
sympy - Build graph structures with
networkx - Visualize using
matplotlibandpyvis - Export graphs to various formats
๐ฎ Phase 2: Function Graphs
- Plot functional relationships
- Show variable dependency graphs
- Evaluate functions over ranges
๐ Phase 3: Dataset Integration (Coming Soon)
- Build correlation graphs from DataFrames
- Analyze feature relationships
- Threshold-based edge creation
๐ง Phase 4: Advanced Features (Planned)
- Auto-detect independent/dependent variables
- Bipartite graph visualization
- Export to
.graphml,.png, etc. - AI-based function simplification
๐ 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 functionvisualize(bool): Whether to show visualizationfunc_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 logic
โ โโโ graph_builder.py # NetworkX graph creation
โ โโโ visualizer.py # Matplotlib/Pyvis visualization
โ โโโ dataset.py # Dataset โ graph (future)
โ
โโโ 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
๐ License
MIT License - feel free to use this project however you'd like!
๐ค Contributing
Contributions are welcome! Please read CONTRIBUTING.md for details on our code of conduct and the process for submitting pull requests.
๐ Publishing
To publish this package to PyPI for others to use, see PUBLISHING.md for detailed instructions.
๐ Changelog
See CHANGELOG.md for version history and release notes.
๐ Tech Stack
- sympy โ Symbolic mathematics and parsing
- networkx โ Graph creation and analysis
- pyvis โ Interactive network visualization
- matplotlib โ Static plotting
- numpy โ Numerical computations
๐ Use Cases
For Students
- Visualize how equations are structured
- Understand operator precedence
- See variable relationships clearly
For Educators
- Create interactive math visualizations
- Demonstrate equation parsing
- Teaching tool for graph theory
For Researchers
- Analyze mathematical formula structure
- Study equation complexity
- Visualize algorithm dependencies
For Developers
- Parse mathematical expressions
- Build equation-based applications
- Create mathematical documentation
๐ฎ Contact
For questions or suggestions, please open an issue on GitHub.
โญ Show Your Support
If you find numgraph helpful, please give it a star on GitHub!
๐ Acknowledgments
Built with these amazing libraries:
- SymPy - Symbolic mathematics
- NetworkX - Complex networks
- Matplotlib - Plotting library
- PyVis - Interactive visualizations
Made with โค๏ธ for math and graph enthusiasts!
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
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 numgraph_equation-0.1.0.tar.gz.
File metadata
- Download URL: numgraph_equation-0.1.0.tar.gz
- Upload date:
- Size: 18.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f79c572d58d449ca549c213b128e13f0697e6da4a2c3004259d3ea1edbc14cba
|
|
| MD5 |
18957105ab7d1cd62be46222e15299f5
|
|
| BLAKE2b-256 |
5ebac888adb349a2a8dd38d6c07e3b2f5bd043457c6d1fc92f620dc78766858e
|
File details
Details for the file numgraph_equation-0.1.0-py3-none-any.whl.
File metadata
- Download URL: numgraph_equation-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e0372da9622b2e86ee6074af136f9f6e757c67bea0260d6a2d04b47ce5f4489c
|
|
| MD5 |
8a4a5f79e3c43c2d7f9a38e7df1d1d41
|
|
| BLAKE2b-256 |
b3b41b9a0722087225630ef4335c25655f9dde6c4c8c3f37f7cfba4d5d29d10c
|