{"id":18456651,"url":"https://github.com/eskaliert680/PyGraph","last_synced_at":"2025-04-08T04:35:10.567Z","repository":{"id":239245677,"uuid":"735184281","full_name":"letlovewin/PyGraph","owner":"letlovewin","description":"Graph theory library for Python3 for a mathematics/competitive programming use case. Has BFS/DFS capabilities, uses an adjacency matrix, more to be added.","archived":false,"fork":false,"pushed_at":"2024-05-10T23:18:06.000Z","size":34,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-05-11T00:25:57.858Z","etag":null,"topics":["competitiveprogramming","graph","graptheory","mathematics","python","university"],"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/letlovewin.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":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-12-24T00:58:11.000Z","updated_at":"2024-05-11T00:26:01.015Z","dependencies_parsed_at":"2024-05-11T00:26:00.894Z","dependency_job_id":"895c3286-e656-4017-8bb1-cce88132ba45","html_url":"https://github.com/letlovewin/PyGraph","commit_stats":null,"previous_names":["letlovewin/pygraph"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/letlovewin%2FPyGraph","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/letlovewin%2FPyGraph/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/letlovewin%2FPyGraph/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/letlovewin%2FPyGraph/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/letlovewin","download_url":"https://codeload.github.com/letlovewin/PyGraph/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223303771,"owners_count":17123106,"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":["competitiveprogramming","graph","graptheory","mathematics","python","university"],"created_at":"2024-11-06T08:12:22.059Z","updated_at":"2025-04-08T04:35:05.161Z","avatar_url":"https://github.com/letlovewin.png","language":"Python","readme":"\n# PyGraph\n\nGraph theory library for Python3 for a mathematics/competitive programming use case.\n\n## Usage/Examples\n\n```python\nfrom pygraph import Graph\n\n#Creating a new Graph object\ngraph = Graph()\n\n#Adding three new vertices tagged with the names Alice, Bob, and Casey.\ngraph.addVertex('Alice')\ngraph.addVertex('Bob')\ngraph.addVertex('Casey')\n\n#Adding undirected edges between Alice \u0026 Bob, Bob \u0026 Casey, Casey \u0026 Alice.\ngraph.addUndirectedEdge('Alice','Bob')\ngraph.addUndirectedEdge('Bob','Casey')\ngraph.addUndirectedEdge('Casey','Alice')\n\n#Doing a depth-first traversal from Alice\ndepthFirstTraversal = graph.depthFirstTraversal('Alice')\nprint(depthFirstTraversal)\n\n#Generating an adjacency matrix for the graph\nA = graph.generateAdjacencyMatrix()\nM = A[0] # A[0] is the adjacency matrix. \nMap = A[1] # A[1] is the mapping that allows you to read the matrix, in the case of you having vertices with string values.\nfor i in range(len(M)): #Printing the adjacency matrix\n    for j in range(len(M)):\n        print(M[i][j], end=' ')\n    print('')\nprint(Map) #Printing the mapping from the vertex names to rows \u0026 columns of the matrix\n\n#Generating a directed acyclic graph (DAG) and creating a topological sort using Kahn's algorithm\nG_2 = Graph('G_2')\n\nG_2.addVertex(\"Moreno Valley\")\nG_2.addVertex(\"Riverside\")\nG_2.addVertex(\"San Bernardino\")\n\nG_2.addEdge(\"Moreno Valley\", \"Riverside\")\nG_2.addEdge(\"Riverside\", \"San Bernardino\")\n\ntopologicalSorting = G_2.generateTopologicalSorting()\n\nfor vertex in topologicalSorting:\n    print(vertex, end=' ')\nprint('')\n```\n\nTo use this on your own machine, run\n\n```bash\ngit clone https://github.com/letlovewin/PyGraph.git\n```\n\nand just drag pygraph.py into your own project.\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feskaliert680%2FPyGraph","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feskaliert680%2FPyGraph","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feskaliert680%2FPyGraph/lists"}