apache-age-dijkstra


Nameapache-age-dijkstra JSON
Version 0.2.2 PyPI version JSON
download
home_pagehttps://github.com/Munmud/apache-age-dijkstra
SummaryDijkstra shortest path algorithm using apache age graph database
upload_time2023-02-11 04:07:15
maintainer
docs_urlNone
authorMoontasir Mahmood
requires_python>=3.9
licenseApache2.0
keywords graph database apache age postgresql shotrtest path dijkstra
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Implement Shortest Path (Dijkstra) with Apache AGE

[Apache AGE](https://age.apache.org/) is a PostgreSQL extension that provides graph database functionality. The goal of the Apache AGE project is to create single storage that can handle both relational and graph model data so that users can use standard ANSI SQL along with openCypher, the Graph query language. This repository hosts the development of the Python driver for this Apache extension (currently in Incubator status). Thanks for checking it out.

Apache AGE is:

- **Powerful** -- AGE adds graph database support to the already popular PostgreSQL database: PostgreSQL is used by organizations including Apple, Spotify, and NASA.
- **Flexible** -- AGE allows you to perform openCypher queries, which make complex queries much easier to write.
- **Intelligent** -- AGE allows you to perform graph queries that are the basis for many next level web services such as fraud & intrustion detection, master data management, product recommendations, identity and relationship management, experience personalization, knowledge management and more.

### Features
* Shortest Path implemented using dijkstra algorithm
* Used Apache AGE graph database

## Installation

### Requirements
* Python 3.9 or higher
* This module runs on [psycopg2](https://www.psycopg.org/) and [antlr4-python3](https://pypi.org/project/antlr4-python3-runtime/)

```cmd
sudo apt-get update
sudo apt-get install python3-dev libpq-dev
pip install --no-binary :all: psycopg2
```

### Install via PIP
```cmd
pip install apache-age-dijkstra
pip install antlr4-python3-runtime==4.9.3
```

### Build from Source
```cmd
git clone https://github.com/Munmud/apache-age-dijkstra
cd apache-age-python
python setup.py install
```

### View Samples
- [Shortest Distance between cities](https://github.com/Munmud/apache-age-dijkstra/blob/master/samples/sample1.py)

## Instruction

### Import
```py
from age_dijkstra import Age_Dijkstra
```

### Making connection to postgresql (when using [this docker reepository](https://github.com/Munmud/apache_age))
```py
con = Age_Dijkstra()
con.connect(
    host="localhost",       # default is "172.17.0.2" 
    port="5430",            # default is "5432"
    dbname="postgresDB",    # default is "postgres"
    user="postgresUser",    # default is "postgres"
    password="postgresPW",  # default is "agens"
    printMessage = True     # default is False
)
```

### Get all edges
```py
edges = con.get_all_edge()
```
- structure : 
`
{
    v1 : start_vertex, 
    v2 : end_vertex,
    e : edge_object
}
`

### Get all vertices
```py
nodes = []
for x in con.get_all_vertices():
    nodes.append(x['property_name'])
```

### Create adjacent matrices using edges
```py
init_graph = {}
for node in nodes:
    init_graph[node] = {}
for edge in edges :
    v1 = edge['v1']['vertices_property_name']
    v2 = edge['v2']['vertices_property_name']
    dist = int(edge['e']['edge_property_name'])
    init_graph
    init_graph[v1][v2] = dist
```

### Initialized Graph
```py
from age_dijkstra import  Graph
graph = Graph(nodes, init_graph)
```

### Use dijkstra Algorithm
```py
previous_nodes, shortest_path = Graph.dijkstra_algorithm(graph=graph, start_node="vertices_property_name")
```

### Print shortest Path
```py
Graph.print_shortest_path(previous_nodes, shortest_path, start_node="vertices_property_name", target_node="vertices_property_name")
```

### Create Vertices
```py
con.set_vertices(
    graph_name = "graph_name", 
    label="label_name", 
    property={"key1" : "val1",}
    )
```

### Create Edge
```py
con.set_edge( 
    graph_name = "graph_name", 
    label1="label_name1", 
    prop1={"key1" : "val1",}, 
    label2="label_name2", 
    prop2={"key1" : "val1",}, 
    edge_label = "Relation_name", 
    edge_prop = {"relation_property_name":"relation_property_value"}
)
```

### For more information about [Apache AGE](https://age.apache.org/)
* Apache Incubator Age: https://age.apache.org/
* Github: https://github.com/apache/incubator-age
* Documentation: https://age.incubator.apache.org/docs/
* apache-age-dijkstra GitHub: https://github.com/Munmud/apache-age-dijkstra
* apache-age-python GitHub: https://github.com/rhizome-ai/apache-age-python

### License
[Apache-2.0 License](https://www.apache.org/licenses/LICENSE-2.0)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Munmud/apache-age-dijkstra",
    "name": "apache-age-dijkstra",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": "",
    "keywords": "Graph Database,Apache AGE,PostgreSQL,Shotrtest path,Dijkstra",
    "author": "Moontasir Mahmood",
    "author_email": "moontasir042@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/71/ce/b43e5217dada17adb132deedb3adbf32a865144f6ae6b1170543ad21c455/apache-age-dijkstra-0.2.2.tar.gz",
    "platform": null,
    "description": "# Implement Shortest Path (Dijkstra) with Apache AGE\n\n[Apache AGE](https://age.apache.org/) is a PostgreSQL extension that provides graph database functionality. The goal of the Apache AGE project is to create single storage that can handle both relational and graph model data so that users can use standard ANSI SQL along with openCypher, the Graph query language. This repository hosts the development of the Python driver for this Apache extension (currently in Incubator status). Thanks for checking it out.\n\nApache AGE is:\n\n- **Powerful** -- AGE adds graph database support to the already popular PostgreSQL database: PostgreSQL is used by organizations including Apple, Spotify, and NASA.\n- **Flexible** -- AGE allows you to perform openCypher queries, which make complex queries much easier to write.\n- **Intelligent** -- AGE allows you to perform graph queries that are the basis for many next level web services such as fraud & intrustion detection, master data management, product recommendations, identity and relationship management, experience personalization, knowledge management and more.\n\n### Features\n* Shortest Path implemented using dijkstra algorithm\n* Used Apache AGE graph database\n\n## Installation\n\n### Requirements\n* Python 3.9 or higher\n* This module runs on [psycopg2](https://www.psycopg.org/) and [antlr4-python3](https://pypi.org/project/antlr4-python3-runtime/)\n\n```cmd\nsudo apt-get update\nsudo apt-get install python3-dev libpq-dev\npip install --no-binary :all: psycopg2\n```\n\n### Install via PIP\n```cmd\npip install apache-age-dijkstra\npip install antlr4-python3-runtime==4.9.3\n```\n\n### Build from Source\n```cmd\ngit clone https://github.com/Munmud/apache-age-dijkstra\ncd apache-age-python\npython setup.py install\n```\n\n### View Samples\n- [Shortest Distance between cities](https://github.com/Munmud/apache-age-dijkstra/blob/master/samples/sample1.py)\n\n## Instruction\n\n### Import\n```py\nfrom age_dijkstra import Age_Dijkstra\n```\n\n### Making connection to postgresql (when using [this docker reepository](https://github.com/Munmud/apache_age))\n```py\ncon = Age_Dijkstra()\ncon.connect(\n    host=\"localhost\",       # default is \"172.17.0.2\" \n    port=\"5430\",            # default is \"5432\"\n    dbname=\"postgresDB\",    # default is \"postgres\"\n    user=\"postgresUser\",    # default is \"postgres\"\n    password=\"postgresPW\",  # default is \"agens\"\n    printMessage = True     # default is False\n)\n```\n\n### Get all edges\n```py\nedges = con.get_all_edge()\n```\n- structure : \n`\n{\n    v1 : start_vertex, \n    v2 : end_vertex,\n    e : edge_object\n}\n`\n\n### Get all vertices\n```py\nnodes = []\nfor x in con.get_all_vertices():\n    nodes.append(x['property_name'])\n```\n\n### Create adjacent matrices using edges\n```py\ninit_graph = {}\nfor node in nodes:\n    init_graph[node] = {}\nfor edge in edges :\n    v1 = edge['v1']['vertices_property_name']\n    v2 = edge['v2']['vertices_property_name']\n    dist = int(edge['e']['edge_property_name'])\n    init_graph\n    init_graph[v1][v2] = dist\n```\n\n### Initialized Graph\n```py\nfrom age_dijkstra import  Graph\ngraph = Graph(nodes, init_graph)\n```\n\n### Use dijkstra Algorithm\n```py\nprevious_nodes, shortest_path = Graph.dijkstra_algorithm(graph=graph, start_node=\"vertices_property_name\")\n```\n\n### Print shortest Path\n```py\nGraph.print_shortest_path(previous_nodes, shortest_path, start_node=\"vertices_property_name\", target_node=\"vertices_property_name\")\n```\n\n### Create Vertices\n```py\ncon.set_vertices(\n    graph_name = \"graph_name\", \n    label=\"label_name\", \n    property={\"key1\" : \"val1\",}\n    )\n```\n\n### Create Edge\n```py\ncon.set_edge( \n    graph_name = \"graph_name\", \n    label1=\"label_name1\", \n    prop1={\"key1\" : \"val1\",}, \n    label2=\"label_name2\", \n    prop2={\"key1\" : \"val1\",}, \n    edge_label = \"Relation_name\", \n    edge_prop = {\"relation_property_name\":\"relation_property_value\"}\n)\n```\n\n### For more information about [Apache AGE](https://age.apache.org/)\n* Apache Incubator Age: https://age.apache.org/\n* Github: https://github.com/apache/incubator-age\n* Documentation: https://age.incubator.apache.org/docs/\n* apache-age-dijkstra GitHub: https://github.com/Munmud/apache-age-dijkstra\n* apache-age-python GitHub: https://github.com/rhizome-ai/apache-age-python\n\n### License\n[Apache-2.0 License](https://www.apache.org/licenses/LICENSE-2.0)\n",
    "bugtrack_url": null,
    "license": "Apache2.0",
    "summary": "Dijkstra shortest path algorithm using apache age graph database",
    "version": "0.2.2",
    "split_keywords": [
        "graph database",
        "apache age",
        "postgresql",
        "shotrtest path",
        "dijkstra"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "10f2a2149182f7266deb04d14df9bde4386cb425ed69d70be36c50b1ae588263",
                "md5": "10e7cff53ec42bc0d9f4778090fce7e4",
                "sha256": "d3c7c6b3421f0d20a57d39ef11c4cf26d54cc7d53141377f50d216227ca217de"
            },
            "downloads": -1,
            "filename": "apache_age_dijkstra-0.2.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "10e7cff53ec42bc0d9f4778090fce7e4",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 10108,
            "upload_time": "2023-02-11T04:07:13",
            "upload_time_iso_8601": "2023-02-11T04:07:13.722889Z",
            "url": "https://files.pythonhosted.org/packages/10/f2/a2149182f7266deb04d14df9bde4386cb425ed69d70be36c50b1ae588263/apache_age_dijkstra-0.2.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "71ceb43e5217dada17adb132deedb3adbf32a865144f6ae6b1170543ad21c455",
                "md5": "883e65115e00aa02c53eadd35fa9f2dd",
                "sha256": "3391eccf5f5862016ed47f3a60ab406af27574e7994df7e38063eb2fa62e9672"
            },
            "downloads": -1,
            "filename": "apache-age-dijkstra-0.2.2.tar.gz",
            "has_sig": false,
            "md5_digest": "883e65115e00aa02c53eadd35fa9f2dd",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 9504,
            "upload_time": "2023-02-11T04:07:15",
            "upload_time_iso_8601": "2023-02-11T04:07:15.012074Z",
            "url": "https://files.pythonhosted.org/packages/71/ce/b43e5217dada17adb132deedb3adbf32a865144f6ae6b1170543ad21c455/apache-age-dijkstra-0.2.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-02-11 04:07:15",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "Munmud",
    "github_project": "apache-age-dijkstra",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "apache-age-dijkstra"
}
        
Elapsed time: 0.04326s