{"id":17153697,"url":"https://github.com/ziofil/quantumgraphs","last_synced_at":"2025-10-28T02:01:56.255Z","repository":{"id":71894871,"uuid":"236205746","full_name":"ziofil/QuantumGraphs","owner":"ziofil","description":"A python package for growing random graphs using quantum random walks","archived":false,"fork":false,"pushed_at":"2020-08-03T15:28:13.000Z","size":138,"stargazers_count":19,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-13T12:47:12.708Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ziofil.png","metadata":{"files":{"readme":"README.md","changelog":"changelog.txt","contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-01-25T17:42:55.000Z","updated_at":"2024-04-28T01:59:59.000Z","dependencies_parsed_at":null,"dependency_job_id":"345ac375-a023-42ab-9114-28b3672b60af","html_url":"https://github.com/ziofil/QuantumGraphs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ziofil/QuantumGraphs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ziofil%2FQuantumGraphs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ziofil%2FQuantumGraphs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ziofil%2FQuantumGraphs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ziofil%2FQuantumGraphs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ziofil","download_url":"https://codeload.github.com/ziofil/QuantumGraphs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ziofil%2FQuantumGraphs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279007134,"owners_count":26084247,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-11T02:00:06.511Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-14T21:47:02.483Z","updated_at":"2025-10-11T12:06:09.900Z","avatar_url":"https://github.com/ziofil.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Introduction\nThis package is for growing random graphs and trees by using continuous quantum walks:\n\n1. One or more quantum walkers evolve on a graph, and at random times their wave function collapses on its nodes.\n2. A new node is attached to all the nodes where a walker collapsed.\n\nBy alternatning evolution and collapse and by controlling the average exploration time we can grow graphs and trees with various characteristics.\n\n# Installation\nInstall via `pip`:\n```bash\npip install quantumgraphs\n```\n\nImport like so:\n```python\nfrom quantumgraphs import QGraph, QGraphList\n```\n\n# The QGraph class\n\n## initialization and basic usage\nThe `QGraph` class represents a single graph, which is instantiated as a trivial graph with a single node.\nThe required parameters are the number of quantum walkers and the average exploration time between collapses:\n```python\nG = QGraph(walkers = 1, exploration=0.5)\n```\n\nWe can grow the graph by adding nodes:\n```python\nG.add_nodes(nodes = 100)\n```\nNow the graph `G` has 101 nodes (`G.nodes` returns 101).\n\n## Visualizations\nWe can visualize a graph via\n```python\nG.draw(node_size=30)\n```\n![img](/plots/example_graph.jpg \"Example graph\")\n\nIf we also wish to export the diagram, we can pass a `filename` argument:\n```python\nG.draw(node_size=30, width=0.5, filename = 'example_graph.jpg')\n```\n\n# The QGraphList class\nThe `QGraphList` class is for managing a collection of `QGraph` objects, which are internally stored in a list.\nThe `QGraphList` class contains a number of utilities and it's meant to work in a flexible way.\nThe `repr` of a `QGraphList` object returns a handy Pandas DataFrame with a summary of its contents, which is particularly nice when working in a jupyter notebook environment.\n\n## Initialization and basic usage\n```python\nGL = QGraphList()\n```\nWe populate it by growing random graphs according to the desired specs. This is automatically done in parallel via [p-tqdm](https://github.com/swansonk14/p_tqdm), with a visual bar that indicates the status of the computation:\n```python\nspecs = [{'walkers':w, 'nodes':n, 'exploration':t} for t in [0.1,0.5,1.0] for w in [1,2,3] for n in [100,200]]\nGL.grow_random_graphs(specs*3) # 3 copies of each spec for statistical experiments\n```\nWe can populate the database at any time, any number of times. Each new graph is treated as a distinct object.\nWe can observe a few properties of the graphs by invoking `GL.dataframe`.\n\n## Visualizations\nThe properties of the graphs can be visualized as follows (using [Seaborn](https://seaborn.pydata.org/) internally):\n```python\nax = GL.lineplot(x='exploration', y='diameter', hue='walkers', style='nodes')\nax.set_xscale('log')\n```\n![img](/plots/diameter.jpg \"Diameter plot\")\n\nNotice that the `lineplot` method returns a matplotlib [Axes](https://matplotlib.org/api/axes_api.html#the-axes-class) instance to allow for further customization and export:\n\n```python\nfig = ax.get_figure()\nfig.savefig(\"diameter.pdf\", bbox_inches='tight')\n```\n\n## Utilities\n\n### Filtering elements\nWe can select and/or exclude parts of the collection:\n```python\nGL.select('walkers', [1,2])\n```\n\nAs the `select` and `exclude` methods return new instances of `QGraphList`, we can chain them with any other class method:\n```python\nGL.exclude('walkers', [1]).select('nodes', [200]).lineplot(x='exploration', y='clustering', hue='walkers')\n```\n\n### QGraphList is an iterable sequence:\n`QGraphList` objects are iterable:\n```python\n[g.nodes for g in GL]\n```\nand the elements can be accessed by index (e.g. `graph = GL[3]`).\n\n### Merging QGraphList instances\n`QGraphList` objects can be merged simply by summing them:\n```python\nG1 = QGraphList()\nG1.grow_random_graphs([{'walkers':1, 'nodes':50, 'exploration':0.1}]*5)\nG2 = QGraphList()\nG2.grow_random_graphs([{'walkers':2, 'nodes':50, 'exploration':0.1}]*5)\nGL = G1 + G2 \n```\n\n## Saving and loading\nAs computations with large graphs might become expensive, we can save and load a `QGraphList` object:\n```python\nGL.save('large_database.npy')\n\nGL = QGraphList()\nGL.load('large_database.npy')\n```\nOnce we save a `QGraphList` object, saving becomes automatic every time we add new `QGraph` objects to it.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fziofil%2Fquantumgraphs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fziofil%2Fquantumgraphs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fziofil%2Fquantumgraphs/lists"}