grphpkg


Namegrphpkg JSON
Version 0.0.4 PyPI version JSON
download
home_pagehttps://github.com/vudiep411/grphpkg
SummaryGraph package
upload_time2024-01-15 04:02:20
maintainer
docs_urlNone
authorVu Diep
requires_python
license
keywords python data structure graph visualization
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # grphpkg
**grphpkg** is a simple graph library that has DFS and BFS implemented that you can create your own operation.

## Graph
```python
from grphpkg import Graph
matrix_representation = [
    [0, 1, 0, 1, 0, 0, 0, 0, 1],
    [1, 0, 1, 0, 0, 1, 0, 0, 0],
    [0, 1, 0, 0, 0, 0, 1, 0, 0],
    [1, 0, 0, 0, 1, 0, 0, 1, 0],
    [0, 0, 0, 1, 0, 1, 0, 0, 0],
    [0, 1, 0, 0, 1, 0, 1, 0, 0],
    [0, 0, 1, 0, 0, 1, 0, 1, 0],
    [0, 0, 0, 1, 0, 0, 1, 0, 1],
    [1, 0, 0, 0, 0, 0, 0, 1, 0]
]

g = Graph(matrix_representation)                    # Initialize weighted graph with a matrix
g.print_graph()                                     # Print the graph
g.dfs(0, lambda x: print(str(x)+" ", end=""))       # Run DFS or BFS with custom callback
g.draw_graph()                                      # Graph visualization
```
> Create your callback function and pass it in dfs or bfs to execute your operation
## Weighted Graph
from grphpkg import Graph
```python
matrix = [
    [0, 2, 3, float('inf')],
    [2, 0, 1, 4],
    [3, 1, 0, 5],
    [float('inf'), 4, 5, 0]
]

weighted_graph = WeightedGraph(matrix)              # Initialize weighted graph with a matrix
weighted_graph.print_graph()                        # Print the graph
mst_edges, mst_cost = weighted_graph.prim_mst(0)    # Get minimun spanning and the edges
weighted_graph.draw_graph()                         # Graph visualization

```
## Graph visualization
Call draw graph function
```
g.draw_graph()
```
<img src="./documents/graph.png" width="60%"/>
<img src="./documents/wgraph.png" width="60%"/>


## Installing
```
pip install grphpkg
```

## Documentation


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/vudiep411/grphpkg",
    "name": "grphpkg",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "python,data structure,graph,visualization",
    "author": "Vu Diep",
    "author_email": "vudiep411@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/db/50/987e75c9bfd5f1e12d71bab8c5db6ac53ae112404f6e2aa276730c5f6bb9/grphpkg-0.0.4.tar.gz",
    "platform": null,
    "description": "# grphpkg\n**grphpkg** is a simple graph library that has DFS and BFS implemented that you can create your own operation.\n\n## Graph\n```python\nfrom grphpkg import Graph\nmatrix_representation = [\n    [0, 1, 0, 1, 0, 0, 0, 0, 1],\n    [1, 0, 1, 0, 0, 1, 0, 0, 0],\n    [0, 1, 0, 0, 0, 0, 1, 0, 0],\n    [1, 0, 0, 0, 1, 0, 0, 1, 0],\n    [0, 0, 0, 1, 0, 1, 0, 0, 0],\n    [0, 1, 0, 0, 1, 0, 1, 0, 0],\n    [0, 0, 1, 0, 0, 1, 0, 1, 0],\n    [0, 0, 0, 1, 0, 0, 1, 0, 1],\n    [1, 0, 0, 0, 0, 0, 0, 1, 0]\n]\n\ng = Graph(matrix_representation)                    # Initialize weighted graph with a matrix\ng.print_graph()                                     # Print the graph\ng.dfs(0, lambda x: print(str(x)+\" \", end=\"\"))       # Run DFS or BFS with custom callback\ng.draw_graph()                                      # Graph visualization\n```\n> Create your callback function and pass it in dfs or bfs to execute your operation\n## Weighted Graph\nfrom grphpkg import Graph\n```python\nmatrix = [\n    [0, 2, 3, float('inf')],\n    [2, 0, 1, 4],\n    [3, 1, 0, 5],\n    [float('inf'), 4, 5, 0]\n]\n\nweighted_graph = WeightedGraph(matrix)              # Initialize weighted graph with a matrix\nweighted_graph.print_graph()                        # Print the graph\nmst_edges, mst_cost = weighted_graph.prim_mst(0)    # Get minimun spanning and the edges\nweighted_graph.draw_graph()                         # Graph visualization\n\n```\n## Graph visualization\nCall draw graph function\n```\ng.draw_graph()\n```\n<img src=\"./documents/graph.png\" width=\"60%\"/>\n<img src=\"./documents/wgraph.png\" width=\"60%\"/>\n\n\n## Installing\n```\npip install grphpkg\n```\n\n## Documentation\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Graph package",
    "version": "0.0.4",
    "project_urls": {
        "Homepage": "https://github.com/vudiep411/grphpkg"
    },
    "split_keywords": [
        "python",
        "data structure",
        "graph",
        "visualization"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d8fd2863b44493f4849e402c20989bb81ac076585288007c12d2c9fbf3613d77",
                "md5": "c493564fcba8de220b9ffb9b9ab3445e",
                "sha256": "f020521aef68948dff7773f1b358a286316195f378cebdc1bc35817542f19a89"
            },
            "downloads": -1,
            "filename": "grphpkg-0.0.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c493564fcba8de220b9ffb9b9ab3445e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 8191,
            "upload_time": "2024-01-15T04:02:18",
            "upload_time_iso_8601": "2024-01-15T04:02:18.647259Z",
            "url": "https://files.pythonhosted.org/packages/d8/fd/2863b44493f4849e402c20989bb81ac076585288007c12d2c9fbf3613d77/grphpkg-0.0.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "db50987e75c9bfd5f1e12d71bab8c5db6ac53ae112404f6e2aa276730c5f6bb9",
                "md5": "1fcc433a9c0531d40ef39c42dd18fd6f",
                "sha256": "6a1f940e21676abd7eaf582b6e4ad872ccc1be64adf20bb7b6a7ee297323c2bc"
            },
            "downloads": -1,
            "filename": "grphpkg-0.0.4.tar.gz",
            "has_sig": false,
            "md5_digest": "1fcc433a9c0531d40ef39c42dd18fd6f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 7587,
            "upload_time": "2024-01-15T04:02:20",
            "upload_time_iso_8601": "2024-01-15T04:02:20.436690Z",
            "url": "https://files.pythonhosted.org/packages/db/50/987e75c9bfd5f1e12d71bab8c5db6ac53ae112404f6e2aa276730c5f6bb9/grphpkg-0.0.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-15 04:02:20",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "vudiep411",
    "github_project": "grphpkg",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "grphpkg"
}
        
Elapsed time: 0.16458s