{ "info": { "author": "Eric V. Smith", "author_email": "eric@trueblade.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "========\ntoposort\n========\n\nOverview\n========\n\nImplements a topological sort algorithm.\n\n>From `Wikipedia `_:\nIn computer science, a topological sort (sometimes abbreviated topsort\nor toposort) or topological ordering of a directed graph is a linear\nordering of its vertices such that for every directed edge uv from\nvertex u to vertex v, u comes before v in the ordering.\n\nInput data description\n======================\n\nThe input to the toposort function is a dict describing the\ndependencies among the input nodes. Each key is a dependent node, the\ncorresponding value is a set containing the dependent nodes.\n\nNote that toposort does not care what the input node values mean: it\njust compares them for equality. The examples here usually use\nintegers, but they could be any hashable type.\n\nTypical usage\n=============\n\nThe interpretation of the input data here is: If 2 depends on 11; 9\ndepends on 11, 8 and 10; 10 depends on 11 and 3 (and so on), then in what\norder should we process the items such that all nodes are processed\nbefore any of their dependencies?::\n\n >>> from toposort import toposort, toposort_flatten\n >>> list(toposort({2: {11},\n ... 9: {11, 8, 10},\n ... 10: {11, 3},\n ... 11: {7, 5},\n ... 8: {7, 3},\n ... }))\n [{3, 5, 7}, {8, 11}, {2, 10}, {9}]\n\nAnd the answer is: process 3, 5, and 7 (in any order); then process 8\nand 11; then process 2 and 10; then process 9. Note that 3, 5, and 7\nare returned first because they do not depend on anything. They are\nthen removed from consideration, and then 8 and 11 don't depend on\nanything remaining. This process continues until all nodes are\nreturned, or a circular dependency is detected.\n\nCircular dependencies\n=====================\n\nA circular dependency will raise a CyclicDependencyError, which is\nderived from ValueError. Here 1 depends on 2, and 2 depends on 1::\n\n >>> list(toposort({1: {2},\n ... 2: {1},\n ... }))\n Traceback (most recent call last):\n ...\n toposort.CircularDependencyError: Circular dependencies exist among these items: {1:{2}, 2:{1}}\n\nIn addition, the 'data' attribute of the raised CyclicDependencyError\nwill contain a dict containing the subset of the input data involved\nin the circular dependency.\n\n\nModule contents\n===============\n\n``toposort(data)``\n\nReturns an iterator describing the dependencies among nodes in the\ninput data. Each returned item will be a set. Each member of this set\nhas no dependencies in this set, or in any set previously returned.\n\n``toposort_flatten(data, sort=True)``\n\nLike toposort(data), except that it returns a list of all of the\ndepend values, in order. If sort is true, the returned nodes are sorted within\neach group before they are appended to the result::\n\n >>> toposort_flatten({2: {11},\n ... 9: {11, 8, 10},\n ... 10: {11, 3},\n ... 11: {7, 5},\n ... 8: {7, 3},\n ... })\n [3, 5, 7, 8, 11, 2, 10, 9]\n\nNote that this result is the same as the first example: ``[{3, 5, 7}, {8, 11}, {2, 10}, {9}]``,\nexcept that the result is flattened, and within each set the nodes\nare sorted.\n\n\nTesting\n=======\n\nTo test, run 'python setup.py test'. On python >= 3.0, this also runs the doctests.\n\nChange log\n==========\n\n1.5 2016-10-24 Eric V. Smith\n----------------------------\n\n* When a circular dependency error is detected, raise a specific\n exception, CircularDependencyError, which is a subclass of\n ValueError. The 'data' attribute of the exception will contain the\n data involved in the circular dependency (issue #2). Thanks\n lilydjwg for the initial patch.\n\n* To make building wheels easier, always require setuptools in\n setup.py (issue #5).\n\n* Mark wheel as being universal, that is, supporting both Python 2.7\n and 3.x (issue #7).\n\n1.4 2015-05-16 Eric V. Smith\n----------------------------\n\n* Removed 'test' package, so it won't get installed by bdist_*. It's still\n included in sdists.\n\n* No code changes.\n\n1.3 2015-05-15 Eric V. Smith\n----------------------------\n\n* Fixed change log date.\n\n* No code changes.\n\n1.2 2015-05-15 Eric V. Smith\n----------------------------\n\n* Changed RPM name to python3-toposort if running with python 3.\n\n* No code changes.\n\n1.1 2014-07-24 Eric V. Smith\n----------------------------\n\n* Release version 1.1. No code changes.\n\n* Add a README.txt entry on running the test suite.\n\n* Fix missing test/__init__.py in the sdist.\n\n1.0 2014-03-14 Eric V. Smith\n----------------------------\n\n* Release version 1.0. The API is stable.\n\n* Add MANIFEST.in to MANIFEST.in, so that it is created in the sdist\n (issue #1).\n\n0.2 2014-02-11 Eric V. Smith\n----------------------------\n\n* Modify setup.py to produce a RPM name of python-toposort for bdist_rpm.\n\n0.1 2014-02-10 Eric V. Smith\n----------------------------\n\n* Initial release.\n\n\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://bitbucket.org/ericvsmith/toposort", "keywords": "", "license": "Apache License Version 2.0", "maintainer": "", "maintainer_email": "", "name": "toposort", "package_url": "https://pypi.org/project/toposort/", "platform": "", "project_url": "https://pypi.org/project/toposort/", "project_urls": { "Homepage": "https://bitbucket.org/ericvsmith/toposort" }, "release_url": "https://pypi.org/project/toposort/1.5/", "requires_dist": null, "requires_python": "", "summary": "Implements a topological sort algorithm.", "version": "1.5" }, "last_serial": 2421039, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "17a484ec16f94a427a63d7e65d575fd4", "sha256": "8ad24944e103847e52d3c6d552bd0b4985117317837489f7f6164076500834f3" }, "downloads": -1, "filename": "toposort-0.1.tar.gz", "has_sig": false, "md5_digest": "17a484ec16f94a427a63d7e65d575fd4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8761, "upload_time": "2014-02-10T19:12:06", "url": "https://files.pythonhosted.org/packages/65/8c/0fe5a4688b544599e232cf6ca13bad22ef7118270d26a7a8de4059436bda/toposort-0.1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "29d3335eb0da0d93c61fff710440f32c", "sha256": "5ea7cfdf183e12b4cd4ffb4132b6f101fef04982be1a8b949d2fdb1b9007dd84" }, "downloads": -1, "filename": "toposort-0.2.tar.gz", "has_sig": false, "md5_digest": "29d3335eb0da0d93c61fff710440f32c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9042, "upload_time": "2014-02-12T01:58:07", "url": "https://files.pythonhosted.org/packages/17/19/b1c46beb8899b5dc5b6cde57f0e82fcaa45911c62ca71176de93b092bc36/toposort-0.2.tar.gz" } ], "1.0": [ { "comment_text": "", "digests": { "md5": "fa675f0ae4482a9d1822a8ee8cbb36c1", "sha256": "df374ee552b698f299eb7c962c3a0b4329958cad52a063840ae2ece83b7c69cd" }, "downloads": -1, "filename": "toposort-1.0.tar.gz", "has_sig": false, "md5_digest": "fa675f0ae4482a9d1822a8ee8cbb36c1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9268, "upload_time": "2014-03-15T02:13:48", "url": "https://files.pythonhosted.org/packages/60/bb/2939d0a1b9f8b32bb0fcb47c396a274dd03ce99b3923600cec62ffc37b0c/toposort-1.0.tar.gz" } ], "1.1": [ { "comment_text": "", "digests": { "md5": "87c0d8de376953997eb092ca150064d8", "sha256": "6a38cbe627260729633e744b5a94a35adbcd0c2277209ccfcc3db5ca578ef5c7" }, "downloads": -1, "filename": "toposort-1.1.tar.gz", "has_sig": false, "md5_digest": "87c0d8de376953997eb092ca150064d8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9433, "upload_time": "2014-07-24T21:11:33", "url": "https://files.pythonhosted.org/packages/6b/5e/4911a71097899d87850926d345160ffb87e626aa796f64ea7216b24df04e/toposort-1.1.tar.gz" } ], "1.3": [ { "comment_text": "", "digests": { "md5": "af40a2a2eac9a1aaf79179a865e1690d", "sha256": "12ad9cab28988036526875c39129359bd84df34f69946d0f7a0f49631d86c238" }, "downloads": -1, "filename": "toposort-1.3.tar.gz", "has_sig": false, "md5_digest": "af40a2a2eac9a1aaf79179a865e1690d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9557, "upload_time": "2015-05-15T11:48:20", "url": "https://files.pythonhosted.org/packages/ba/70/fa8b1b3c31e4fa9d09625cb23e248d1f76485e8b9bc801e34f831fe66af3/toposort-1.3.tar.gz" } ], "1.4": [ { "comment_text": "", "digests": { "md5": "02433c00de9eaecf494245c4bca5e922", "sha256": "c190b9d9a9e53ae2835f4d524130147af601fbd63677d19381c65067a80fa903" }, "downloads": -1, "filename": "toposort-1.4.tar.gz", "has_sig": false, "md5_digest": "02433c00de9eaecf494245c4bca5e922", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9626, "upload_time": "2015-05-16T17:18:26", "url": "https://files.pythonhosted.org/packages/f6/f7/875e23067652488ae40603336fdd63510a1e1853672b5b829a78452fd31c/toposort-1.4.tar.gz" } ], "1.5": [ { "comment_text": "", "digests": { "md5": "c0052441d5e3f94872e22200aa6a34b1", "sha256": "d80128b83b411d503b0cdb4a8f172998bc1d3b434b6402a349b8ebd734d51a80" }, "downloads": -1, "filename": "toposort-1.5-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "c0052441d5e3f94872e22200aa6a34b1", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7602, "upload_time": "2016-10-25T01:05:38", "url": "https://files.pythonhosted.org/packages/e9/8a/321cd8ea5f4a22a06e3ba30ef31ec33bea11a3443eeb1d89807640ee6ed4/toposort-1.5-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "472cf86871d19b66d7cb18412c026959", "sha256": "dba5ae845296e3bf37b042c640870ffebcdeb8cd4df45adaa01d8c5476c557dd" }, "downloads": -1, "filename": "toposort-1.5.tar.gz", "has_sig": false, "md5_digest": "472cf86871d19b66d7cb18412c026959", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10294, "upload_time": "2016-10-25T01:05:40", "url": "https://files.pythonhosted.org/packages/e5/d8/9bc1598ddf74410beba243ffeaee8d0b3ca7e9ac5cefe77367da497433e1/toposort-1.5.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "c0052441d5e3f94872e22200aa6a34b1", "sha256": "d80128b83b411d503b0cdb4a8f172998bc1d3b434b6402a349b8ebd734d51a80" }, "downloads": -1, "filename": "toposort-1.5-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "c0052441d5e3f94872e22200aa6a34b1", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7602, "upload_time": "2016-10-25T01:05:38", "url": "https://files.pythonhosted.org/packages/e9/8a/321cd8ea5f4a22a06e3ba30ef31ec33bea11a3443eeb1d89807640ee6ed4/toposort-1.5-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "472cf86871d19b66d7cb18412c026959", "sha256": "dba5ae845296e3bf37b042c640870ffebcdeb8cd4df45adaa01d8c5476c557dd" }, "downloads": -1, "filename": "toposort-1.5.tar.gz", "has_sig": false, "md5_digest": "472cf86871d19b66d7cb18412c026959", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10294, "upload_time": "2016-10-25T01:05:40", "url": "https://files.pythonhosted.org/packages/e5/d8/9bc1598ddf74410beba243ffeaee8d0b3ca7e9ac5cefe77367da497433e1/toposort-1.5.tar.gz" } ] }