Metadata-Version: 2.3
Name: pyMogwai
Version: 0.0.7
Summary: PyMogwai is a Python-based implementation of the Gremlin graph traversal language, designed to create and handle knowledge graphs entirely in Python without the need for an external Gremlin server.
Project-URL: Home, https://github.com/juupje/pyMogwai
Project-URL: Documentation, https://cr.bitplan.com/index.php/pyMogwai
Project-URL: Source, https://github.com/juupje/pyMogwai
Author-email: Joep Geuskens <joep.geuskens@rwth-aachen.de>, Wolfgang Fahl <wf@bitplan.com>
Maintainer-email: Joep Geuskens <joep.geuskens@rwth-aachen.de>, Wolfgang Fahl <wf@bitplan.com>
License: Apache-2.0
Keywords: graph traversal,gremlin,knowledge graph,nicegui,pyMogwai
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Education
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Requires-Dist: networkx==3.3
Requires-Dist: pydot>=2.0.0
Requires-Dist: pygraphviz>=0.20.3
Requires-Dist: pypdf>=4.2.0
Requires-Dist: pysemanticslides==0.0.10
Provides-Extra: gui
Requires-Dist: ngwidgets>=0.19.2; extra == 'gui'
Requires-Dist: nicegui>=2.5.0; extra == 'gui'
Provides-Extra: lod
Requires-Dist: pylodstorage>=0.13.3; extra == 'lod'
Provides-Extra: test
Requires-Dist: green; extra == 'test'
Description-Content-Type: text/markdown

# PyMogwai
PyMogwai is a Python-based implementation of the Gremlin graph traversal language, designed to create and handle knowledge graphs entirely in Python without the need for an external Gremlin server.

[![pypi](https://img.shields.io/pypi/pyversions/pyMogwai)](https://pypi.org/project/pyMogwai/)
[![Github Actions Build](https://github.com/juupje/pyMogwai/actions/workflows/build.yml/badge.svg)](https://github.com/juupje/pyMogwai/actions/workflows/build.yml)
[![PyPI Status](https://img.shields.io/pypi/v/pyMogwai.svg)](https://pypi.python.org/pypi/pyMogwai/)
[![GitHub issues](https://img.shields.io/github/issues/juupje/pyMogwai.svg)](https://github.com/juupje/pyMogwai/issues)
[![GitHub closed issues](https://img.shields.io/github/issues-closed/juupje/pyMogwai.svg)](https://github.com/juupje/pyMogwai/issues/?q=is%3Aissue+is%3Aclosed)
[![API Docs](https://img.shields.io/badge/API-Documentation-blue)](https://juupje.github.io/pyMogwai/)
[![License](https://img.shields.io/github/license/juupje/pyMogwai.svg)](https://www.apache.org/licenses/LICENSE-2.0)

## Features
* Supports knowledge graph creation and manipulation
* Supports the import of arbitrary knowledge graphs with GraphML
* Implements a variety of traversal steps
* Enables one to traverse a graph with these steps
* Ability to integrate data from various sources like Excel, PDF and PowerPoint
* Simple and Pythonic API for graph operations

## Demo
[nicegui based demo](https://mogwai.bitplan.com/)


## Getting started

### Creating a Knowledge Graph
To create a graph using PyMogwai
```python
from mogwai.core import MogwaiGraph
graph = MogwaiGraph()

# Add nodes and edges
n1 = graph.add_labeled_node("person", name="Alice", properties={"Age": 30})
n2 = graph.add_labeled_node("person", name="Bob", properties={"Age": 28})
graph.add_labeled_edge(n1, n2, "knows")
```
### Import graphs
```python
from mogwai.parser.graphml_converter import graphml_to_mogwaigraph

graph = graphml_to_mogwaigraph(path, node_label_key="node_label", node_name_key="node_name", edge_label_key="edge_label")
```

### Performing Traversals
To perform any traversal of the graph, create a TraversalSource. Traversals start with a start step (`V()` or `E()`), which is followed by a sequence of steps. Note that a traversal can be executed by calling `.run()` on it.


```python
from mogwai.core.traversal import MogwaiGraphTraversalSource

g = MogwaiGraphTraversalSource(graph)

# Example traversal that returns every person in the graph as a list
res = g.V().has_label("person").to_list().run()
print(res)
```

In order to use anonymous traversal in complex queries, import the statics module:

```python
from mogwai.core.traversal import MogwaiGraphTraversalSource
from mogwai.core.steps.statics import *

g = MogwaiGraphTraversalSource(graph)

# Example traversal that returns every person in the graph as a list
query = g.V().has_label("person").filter_(properties('age').is_(gte(30))).to_list().by('name')
res = query.run()
print(res)
```

# History
This project started as part of the  [RWTH Aachen i5 Knowledge Graph Lab SS2024](https://dbis.rwth-aachen.de/dbis/index.php/2023/knowledge-graph-lab-ss-2024/)
The original source is hosted at https://git.rwth-aachen.de/i5/teaching/kglab/ss2024/pymogwai
2024-08-15 the repository moved to github for better pypi integration