{"id":22499736,"url":"https://github.com/mahdavipanah/coloredspanningtree","last_synced_at":"2025-03-27T22:25:52.499Z","repository":{"id":146016564,"uuid":"72822710","full_name":"mahdavipanah/ColoredSpanningTree","owner":"mahdavipanah","description":"A solution for a multicolored spanning trees problem","archived":false,"fork":false,"pushed_at":"2019-09-22T17:27:27.000Z","size":11,"stargazers_count":2,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-02T00:41:24.594Z","etag":null,"topics":["algorithm","python","spanningtrees","tree"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mahdavipanah.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-11-04T07:03:53.000Z","updated_at":"2019-11-24T20:24:19.000Z","dependencies_parsed_at":null,"dependency_job_id":"26ace063-55c8-49cb-9fbe-3032f7205eb8","html_url":"https://github.com/mahdavipanah/ColoredSpanningTree","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mahdavipanah%2FColoredSpanningTree","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mahdavipanah%2FColoredSpanningTree/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mahdavipanah%2FColoredSpanningTree/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mahdavipanah%2FColoredSpanningTree/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mahdavipanah","download_url":"https://codeload.github.com/mahdavipanah/ColoredSpanningTree/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245933247,"owners_count":20696200,"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","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":["algorithm","python","spanningtrees","tree"],"created_at":"2024-12-06T22:15:36.406Z","updated_at":"2025-03-27T22:25:52.460Z","avatar_url":"https://github.com/mahdavipanah.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Problem description\n## Multicolored Spanning Trees (Compulsory)\nSuppose that you have a connected, undirected graph G = (V, E) where each edge is colored either red or blue.\nGiven a number k, you are interested in determining whether there is some spanning tree of G that contains\nexactly k blue edges.\n* Design a polynomial-time algorithm that finds a spanning tree of G containing the minimum possible number of blue edges. Then:\n  * Describe your algorithm.\n  * Prove that your algorithm finds a spanning tree of G containing the minimum possible number of blue edges.\n  * Prove that your algorithm runs in polynomial time.\n* Design an algorithm that finds a spanning tree of G containing the maximum possible number of blue edges. Then:\n  * Describe your algorithm.\n  * Prove that your algorithm finds a spanning tree of G containing the maximum possible number\n  *f blue edges.\n  * Prove that your algorithm runs in polynomial time.\n* Design an algorithm that, given a number k, determines whether there is a spanning tree of G\nthat contains exactly k blue edges. Note that you don't need to find such a spanning tree; you just need\nto determine whether one exists. Your algorithm should run in time polynomial in n and m (the number\nof nodes and edges in G), but not in k. Then:\n  * Describe your algorithm.\n  * Briefly justify why your algorithm determines whether there is a spanning tree of G containing\n  exactly k blue edges. You don't need to write a formal proof here, but should give a one-paragraph\n  justification as to why your algorithm works.\n  * Briefly justify why your algorithm runs in time polynomial in n and m.\n\n\n# Project's files\n\n* main.py: First and second problem's section's program.\n* k.py: Third section of the problem's program.\n* input.py: Reads and writes a graph adjacency matrix from and into a file (used by main.py and k.py)\n* tree.py: Functionalities for drawing a tree structure in command line.\n* input.txt: Input file which you should place your adjacency matrix of the graph you want to be caluculated in it.\n* .gitignore: Files and folders to get ignored by git.\n\n\n\n# Input rules\n\n## The first section\nSuppose W[i][j] is one of the items in adjacency matrix:\n\nW[i][j] =\n* **0** *if i = j*\n* **1** *if edge is red*\n* **2** *if edge is blue*\n* **3** *if there is not edge between v\u003csub\u003ei\u003c/sub\u003e and v\u003csub\u003ej\u003c/sub\u003e*\n\n\n## The Second section\nSuppose W[i][j] is one of the items in adjacency matrix:\n\nW[i][j] =\n* **0** *if i = j*\n* **1** *if edge is blue*\n* **2** *if edge is red*\n* **3** *if there is not edge between v\u003csub\u003ei\u003c/sub\u003e and v\u003csub\u003ej\u003c/sub\u003e*\n\n\n## The third section\nSame as first section.\n\n\n# Prerequisites\n* Python2 *(python 2.7 is prefered)*\n* [asciitree python package](https://github.com/mbr/asciitree):\n```\npip2 install asciitree\n```\n\n# Useful links\n* https://en.wikipedia.org/wiki/Prim%27s_algorithm\n* http://stackoverflow.com/questions/21706003/finding-a-spanning-tree-using-exactly-k-red-edges-in-a-graph-with-edges-colored\n* https://en.wikipedia.org/wiki/Graph_coloring\n* https://en.wikipedia.org/wiki/Spanning_tree\n* https://en.wikipedia.org/wiki/Minimum_spanning_tree\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmahdavipanah%2Fcoloredspanningtree","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmahdavipanah%2Fcoloredspanningtree","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmahdavipanah%2Fcoloredspanningtree/lists"}