{ "info": { "author": "Luciano Bello", "author_email": "luciano (a) debian (*) org", "bugtrack_url": null, "classifiers": [], "description": "python-lattice\n==============\nPython library to operate elements of a finite lattice\n\n\nA finite lattice is an algebraic structure in which any two elements have a\nunique supremum and an infimum. More info at the wikipedia page. There is no\nlimitation in the element class (supports unhashable types) and a Hasse diagram\ncan be created. Comments of any kind are welcome.\nUsage and Example 1\n-------------------\nGiven the power set of { x, y, z } partially ordered by inclusion.\nIn this case, the join and meet operation is the union and intersection between\nsets, respectively.\n\t>>> powerset=[set(),set(['x']),set(['y']),set(['z']),set(['x','y']),set(['x','z']),set(['y','z']),set(['x','y','z'])]\n\t>>> def intersection(a,b): return a&b \n\t... \n\t>>> def union(a,b): return a|b \n\t... \n\nThe lattice may be defined as following.\n\t>>> from lattice import Lattice\n\t>>> L=Lattice(powerset,union,intersection)\n\t>>> L\n\tLattice([set([]), set(['x']), set(['y']), set(['z']), set(['y', 'x']), set(['x', 'z']), set(['y', 'z']), set(['y', 'x', 'z'])],,)\n\nThe elements can be created by referencing the original object or by indexing in\nLattice.Uelements. The lattice's top and bottom can be access by\nLattice.TopElement and Lattice.BottonElement:\n\t>>> set_with_x=L.wrap(set(['x']))\n\t>>> set_with_x\n\tLatticeElement(L, set(['x']))\n\t>>> set_with_x.unwrap\n\tset(['x'])\n\t>>> emptyset=L.wrap(set([]))\n\t>>> emptyset == L.BottonElement\n\tTrue \n\t>>> L.TopElement\n\tLatticeElement(L, set(['y', 'x', 'z']))\n\t>>> set_with_y=L.wrap(set(['y']))\n\t>>> set_with_yz=L.wrap(set(['y','z']))\n\nThe lattice elements supports the following operations:\n\t>>> set_with_x | set_with_yz # join\n\tLatticeElement(L, set(['y', 'x', 'z']))\n\t>>> set_with_y & set_with_yz # meet\n\tLatticeElement(L, set(['y']))\n\t>>> set_with_x & set_with_yz == emptyset # equal \n\tTrue\n\t>>> set_with_y <= set_with_yz #partial order relation\n\tTrue\n\t>>> set_with_x <= set_with_yz #partial order relation\n\tFalse\n\nTo graph a Hasse diagram based on the created lattice run Lattice.Hasse(). This\nwill return graphviz code. If scapy is installed (this condition will be removed\nin the future), it will appear the graph.\n\t>>> print L.Hasse()\n\tdigraph G {\n\tsplines=\"line\"\n\trankdir=BT\n\t\"set(['y', 'x', 'z'])\" [shape=box];\n\t\"set([])\" [shape=box];\n\t\"set([])\" -> \"set(['x'])\";\n\t\"set([])\" -> \"set(['y'])\";\n\t\"set([])\" -> \"set(['z'])\";\n\t\"set(['x'])\" -> \"set(['y', 'x'])\";\n\t\"set(['x'])\" -> \"set(['x', 'z'])\";\n\t\"set(['y'])\" -> \"set(['y', 'x'])\";\n\t\"set(['y'])\" -> \"set(['y', 'z'])\";\n\t\"set(['z'])\" -> \"set(['x', 'z'])\";\n\t\"set(['z'])\" -> \"set(['y', 'z'])\";\n\t\"set(['y', 'x'])\" -> \"set(['y', 'x', 'z'])\";\n\t\"set(['x', 'z'])\" -> \"set(['y', 'x', 'z'])\";\n\t\"set(['y', 'z'])\" -> \"set(['y', 'x', 'z'])\";\n\t}\n\n\nExample 2\n---------\n\t>>> from lattice import Lattice\n\t>>> def gcd(a,b):\n\t... while b > 0: a,b = b, a%b \n\t... return a\n\t... \n\t>>> def lcm(a, b): \n\t... return a*b/gcd(a,b)\n\t... \n\t>>> L=Lattice([ 1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30, 60 ],lcm,gcd)\n\t>>> L.Hasse()\n\tdigraph G {\n\tsplines=\"line\"\n\trankdir=BT\n\t\"60\" [shape=box];\n\t\"1\" [shape=box];\n\t\"1\" -> \"2\";\n\t\"1\" -> \"3\";\n\t\"1\" -> \"5\";\n\t\"2\" -> \"4\";\n\t\"2\" -> \"6\";\n\t\"2\" -> \"10\";\n\t\"3\" -> \"6\";\n\t\"3\" -> \"15\";\n\t\"4\" -> \"12\";\n\t\"4\" -> \"20\";\n\t\"5\" -> \"10\";\n\t\"5\" -> \"15\";\n\t\"6\" -> \"12\";\n\t\"6\" -> \"30\";\n\t\"10\" -> \"20\";\n\t\"10\" -> \"30\";\n\t\"12\" -> \"60\";\n\t\"15\" -> \"30\";\n\t\"20\" -> \"60\";\n\t\"30\" -> \"60\";\n\t}", "description_content_type": null, "docs_url": "https://pythonhosted.org/python-lattice/", "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://code.google.com/p/python-lattice/", "keywords": null, "license": "LICENSE.txt", "maintainer": null, "maintainer_email": null, "name": "python-lattice", "package_url": "https://pypi.org/project/python-lattice/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/python-lattice/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://code.google.com/p/python-lattice/" }, "release_url": "https://pypi.org/project/python-lattice/0.0.2/", "requires_dist": null, "requires_python": null, "summary": "Python library to operate elements of a finite lattice", "version": "0.0.2" }, "last_serial": 229297, "releases": { "0.0.2": [] }, "urls": [] }