{"id":24737495,"url":"https://github.com/engineersbox/planargraphs","last_synced_at":"2025-09-03T06:34:41.293Z","repository":{"id":109327061,"uuid":"222190878","full_name":"EngineersBox/PlanarGraphs","owner":"EngineersBox","description":null,"archived":false,"fork":false,"pushed_at":"2019-11-18T09:02:38.000Z","size":11,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-22T17:44:52.634Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/EngineersBox.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2019-11-17T03:18:17.000Z","updated_at":"2019-11-18T09:02:40.000Z","dependencies_parsed_at":"2023-03-08T09:30:31.784Z","dependency_job_id":null,"html_url":"https://github.com/EngineersBox/PlanarGraphs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/EngineersBox/PlanarGraphs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EngineersBox%2FPlanarGraphs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EngineersBox%2FPlanarGraphs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EngineersBox%2FPlanarGraphs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EngineersBox%2FPlanarGraphs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EngineersBox","download_url":"https://codeload.github.com/EngineersBox/PlanarGraphs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EngineersBox%2FPlanarGraphs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273403937,"owners_count":25099299,"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-09-03T02:00:09.631Z","response_time":76,"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":"2025-01-27T22:08:32.809Z","updated_at":"2025-09-03T06:34:41.281Z","avatar_url":"https://github.com/EngineersBox.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PlanarGraphs\n\nAn undirected graph in discrete mathematics is a collection of verticies (V) and edges (E), generally defined as G=(V,E). A planar graph is any graph that can be drawn with no verticies crossing over. An example of this is the K4 graph:\n![K4 Planar Graph](https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fi.stack.imgur.com%2FwQa6X.gif\u0026f=1\u0026nofb=1)\n\nThere are several ways to determine whether a graph is planar or not, two of these are:\n- Kuratowski's theorem\n- Euler's characteristic\n\n#### Kuratowski's Theorem\n\nTo understand Kuratowski's theorem, we first need to understand two lemmas:\n\n##### Lemma 1:\n\u003eAn elementary subdivision of a non-empty graph G=(V,E) is obtained from G by removing the edge between the veriticies *(u,v)* and adding a new vertex *w* (that is not already part of the graph), add then adding the edges *(u,w)* and *(v,w)*.\n\n##### Lemma 2:\n\u003eA subdivision of graph G=(V,E) is a graph obtained from G by applying the following recursive definition:\n\u003e1. G is a subdivision of G\n\u003e2. If H1 is an elementary subdivision of G and H2 is an elementary subdivision of H1, then H2 is a subdivision of G.\n\nNow we can look at Kuratowski's theorem, that states:\n\u003eA graph G=(V,E) is planar if and only if G does not contain a subgraph H that is isomorphic to a subdivision of K5 or K3,3.\n\nTo see this in action, lets look at the Peterson graph:\\\n![Peterson Graph](https://i.ibb.co/RSk0Dgq/peterson-graph.png)\\\nWhich has an isomorphic subdivision to K3,3:\\\n![K3,3 Isomorphic Subdivision Peterson Graph](https://i.ibb.co/LzbK48v/peterson-k33.png)\n\n#### Euler's Characterisic\n\nPlanar graphs have a specific property known as faces, these are areas bounded by edges in the graph and the space outside the graph. For example, here are all the faces (labeled with fn for each) of a graph:\n![Planar Graph Faces](https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fi.stack.imgur.com%2FuxTmT.png\u0026f=1\u0026nofb=1)\n\nEuler's characteristc states:\n\u003eLet G=(V,E) be a connected planar graph and v=|V|, e=|E|, r=|faces(G)|. Then,\n\u003e*v-e+r=2*\n\n## Implementation\n\nNow that we understand planar graph and how to determine them, let's look at this repo. This is a JavaScrip + p5.js implementation of a game where a random planar graph is generated with mixed up locations for the veritcies, your job is to un-mix them so that no edges cross over.\n\nHere the QuadTree code from my [QuadTree repo](https://github.com/EngineersBox/QuadTrees) is used to generate a random quadtree with n verticies and a capacity of 1. A graph is then generated by created edges between all quads with Von Neumann neighbours with Manhattan distance 1. Then the verticies are given random locations of the canvas to produce the mixed up state.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fengineersbox%2Fplanargraphs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fengineersbox%2Fplanargraphs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fengineersbox%2Fplanargraphs/lists"}