{ "info": { "author": "Claudia Lazara Poiet Sampedro, Igor Neves Faustino, Leticia Mazzo Portela", "author_email": "clp.sampedro@gmail.com, igornfaustino@gmail.com, leticiaportela@alunos.utfpr.edu.br", "bugtrack_url": null, "classifiers": [], "description": "# graphpy\n\nThis is a package for the manipulation of graphs\nmade for a class of graphs in the Brazilian university 'Universidade Tecnologica Federal do Paran\u00e1'\n\n## Installation\n\n```\npip install graphpython\n```\n\n## Complete Documentation\n\n### Graph\n\nto use this class, the main element is `Graph class`. With this class, you will be able to fill the graph with vertex and edges and do all the necessary operations\n\n- `Graph([directed])`: create a graph\n - `directed`: Defaults to False.\n tells if the graph is directed or not\n\n#### Code example\n\n``` python\n# Create a new graph\nfrom graphpy.graph import Graph\n\ngp = Graph()\n# add a new vertex\ngp.add_vertex('vertex1')\n\n# to get the create vertex, you can use the [] operator\nvertex1 = gp['vertex1']\n```\n\n### Vertex operations\n\nThe base of all graph is the vertex, to create a new vertex you got to use the follow functions\n\n- `gp.add_vertex(name, [value])`: create a new vertex and insert to the graph\n - `name`: Unique identification to the vertex inside the graph\n - `value`: optional value to the vertex\n\n- `gp.get_vertex(name)` or `gp[name]`: return the vertex from the graph\n - `name`: Unique identification to the vertex inside the graph\n\n- `gp.get_all_vertex()`: get a list with all vertex from the graph\n\n- `gp.adjacents_vertex(vtx)`: get all adjacent vertex from one vertex\n - `vtx`: vertex you want to know the adjacent\n\n- `gp.remove_vertex(vertex_to_remove)`: Remove a vertex and all the connections he have\n - `vertex_to_remove`: vertex you want to remove\n\n#### Code example\n\n```python\nfrom graphpy.graph import Graph\n\ngp = Graph()\ngp.add_vertex('01')\ngp.remove_vertex(gp['01'])\n```\n\n## Search in the graph\n\nThe main class has a search method and to use, you need to pass a by params an strategy to make the search.\n\n#### Implement a new search strategy\n\nIn the class has two class strategies already implemented:\n\n- BFSstrategy\n- DFSstrategy\n\n```python\nfrom graphpy.graph import Graph\nfrom graphpy.BFSstrategy import BFSstrategy\n\ngraph = Graph()\ngraph.search(BFSstrategy(INITIAL_VERTEX))\n```\n\nTo extend all the search types you can create a new strategy extending the SearchStrategy class from search_strategy.\n\n```python\nfrom graphpy.search_strategy import SearchStrategy\n\n\nclass DFSstrategy(SearchStrategy):\n def __init__(self):\n\n self.__predecessors = {}\n self.__firstSee = {}\n self.__close = {}\n self.__time = 0\n\n def __dfs_visit(self, vertex):\n self.__time = self.__time + 1\n self.__firstSee[vertex] = self.__time\n vertex.set_color(1)\n\n for adjacent in self.get_adjacent_list()[vertex]:\n if adjacent.get_color() == 0:\n self.__predecessors[adjacent] = vertex\n self.__dfs_visit(adjacent)\n vertex.set_color(2)\n self.__time += 1\n self.__close[vertex] = self.__time\n\n def search(self):\n # colors:\n # white: not visited\n # grey: in the queue\n # black: nothing more to do\n for key in self.get_adjacent_list():\n # set color for all vertices to white\n key.set_color(0)\n self.__predecessors[key] = None\n self.__time = 0\n for key in self.get_adjacent_list():\n if key.get_color() == 0:\n self.__dfs_visit(key)\n\n return self.__firstSee, self.__close, self.__predecessors\n```\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/igornfaustino/graphpy", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "graphpython", "package_url": "https://pypi.org/project/graphpython/", "platform": "", "project_url": "https://pypi.org/project/graphpython/", "project_urls": { "Homepage": "https://github.com/igornfaustino/graphpy" }, "release_url": "https://pypi.org/project/graphpython/0.83/", "requires_dist": [ "six" ], "requires_python": "", "summary": "package to manipulate graphs", "version": "0.83" }, "last_serial": 4202335, "releases": { "0.83": [ { "comment_text": "", "digests": { "md5": "646a0f2cb48333ee8cafe2abe9e1ec94", "sha256": "f505a5d185a41906e47ada57b30a039e8a46909c01c50e25f583334c19e103cd" }, "downloads": -1, "filename": "graphpython-0.83-py3-none-any.whl", "has_sig": false, "md5_digest": "646a0f2cb48333ee8cafe2abe9e1ec94", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8261, "upload_time": "2018-08-24T04:38:50", "url": "https://files.pythonhosted.org/packages/10/1d/61642fe7f6b8daafd53b403a51e467f23249a465457ecbd01c343916cea2/graphpython-0.83-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "71cc166bdc92ca763c06e95e7f9e6263", "sha256": "617ad3c4602d9d5f0cb13f9db245975d823b8751292a2a17d6c99bb9927dda8b" }, "downloads": -1, "filename": "graphpython-0.83.tar.gz", "has_sig": false, "md5_digest": "71cc166bdc92ca763c06e95e7f9e6263", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6358, "upload_time": "2018-08-24T04:38:51", "url": "https://files.pythonhosted.org/packages/0f/cf/39aa3211db3362334df12c44a57c40a8f5b8fc40a55a8d379c3c56c18d32/graphpython-0.83.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "646a0f2cb48333ee8cafe2abe9e1ec94", "sha256": "f505a5d185a41906e47ada57b30a039e8a46909c01c50e25f583334c19e103cd" }, "downloads": -1, "filename": "graphpython-0.83-py3-none-any.whl", "has_sig": false, "md5_digest": "646a0f2cb48333ee8cafe2abe9e1ec94", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8261, "upload_time": "2018-08-24T04:38:50", "url": "https://files.pythonhosted.org/packages/10/1d/61642fe7f6b8daafd53b403a51e467f23249a465457ecbd01c343916cea2/graphpython-0.83-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "71cc166bdc92ca763c06e95e7f9e6263", "sha256": "617ad3c4602d9d5f0cb13f9db245975d823b8751292a2a17d6c99bb9927dda8b" }, "downloads": -1, "filename": "graphpython-0.83.tar.gz", "has_sig": false, "md5_digest": "71cc166bdc92ca763c06e95e7f9e6263", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6358, "upload_time": "2018-08-24T04:38:51", "url": "https://files.pythonhosted.org/packages/0f/cf/39aa3211db3362334df12c44a57c40a8f5b8fc40a55a8d379c3c56c18d32/graphpython-0.83.tar.gz" } ] }