{"id":21432405,"url":"https://github.com/mikeleo03/tarjans-simulation_backend","last_synced_at":"2026-05-19T14:39:35.270Z","repository":{"id":187972117,"uuid":"665794120","full_name":"mikeleo03/Tarjans-Simulation_Backend","owner":"mikeleo03","description":"Backend side of SCC and Bridges Finder using Tarjans Algorithm with React Typescript and Golang","archived":false,"fork":false,"pushed_at":"2023-07-14T16:14:35.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-16T22:37:50.299Z","etag":null,"topics":["bridges","golang","react-tsx","scc","tarjan-algorithm"],"latest_commit_sha":null,"homepage":"https://tarjans-simulation-frontend.vercel.app","language":"Go","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/mikeleo03.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}},"created_at":"2023-07-13T02:52:08.000Z","updated_at":"2023-08-13T01:06:52.000Z","dependencies_parsed_at":"2023-08-13T03:21:04.568Z","dependency_job_id":null,"html_url":"https://github.com/mikeleo03/Tarjans-Simulation_Backend","commit_stats":null,"previous_names":["mikeleo03/tarjans-simulation_backend"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mikeleo03/Tarjans-Simulation_Backend","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikeleo03%2FTarjans-Simulation_Backend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikeleo03%2FTarjans-Simulation_Backend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikeleo03%2FTarjans-Simulation_Backend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikeleo03%2FTarjans-Simulation_Backend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mikeleo03","download_url":"https://codeload.github.com/mikeleo03/Tarjans-Simulation_Backend/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikeleo03%2FTarjans-Simulation_Backend/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272466968,"owners_count":24939484,"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-08-28T02:00:10.768Z","response_time":74,"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":["bridges","golang","react-tsx","scc","tarjan-algorithm"],"created_at":"2024-11-22T23:18:26.195Z","updated_at":"2026-05-19T14:39:35.242Z","avatar_url":"https://github.com/mikeleo03.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🕸 Tarjans Algorithm Simulation\n\u003e Backend side of SCC and Bridges Finder using Tarjans Algorithm with React Typescript and Golang\n\n## General Information\nThis program is created to find s Strongly Connected Component (SCC) on a directed Graph and Bridges on a undirected graph based on user input. The program will proceed a.txt file which containt directed adjacency lists to interpret a graph, then find the SCC and Bridges using popular SCC algorithm, Tarjans. User can also modify the graph by adding and deleting edges by filling the form. The program also provide a good graph and edge coloring to make a better undersanding about the results. Furthermore, the project information is also provided for future improvements.\n\n## Project Structure\n```bash\n.\n├─── algorithm\n│   └─── algorithm.go\n├─── middleware\n│   └─── handlers.go\n├─── router\n│   └─── router.go\n├─── go.mod\n├─── go.sum\n├─── main.go\n└─── README.md\n```\n\n## Prerequisites\n- gorilla/mux (v 1.8.0) to handle routing\n- time to hanlde processing time\n- io/ioutil to unmarshal request body\n- net/http to handle request and responseWriter\n- encoding/json to parse the json POST body\n\n## Algorithms\nThus section will explain what is Tarjans Algorithm and how it used to detect Strongly Connected Components (SCC) on directed graph and bridges on undirected graph.\n### What is Tarjans Algorithm\nTarjan's algorithm is a graph traversal algorithm developed by Robert Tarjan in 1972. It is used to find strongly connected components (SCCs) in a directed graph. SCCs are subgraphs in which there is a path between any two vertices.\n\nTarjan's algorithm is based on depth-first search (DFS) and uses a concept called the \"low-link value\" to determine SCCs. The algorithm assigns a unique identifier called a \"DFS number\" to each vertex during the DFS traversal. It also maintains a stack of vertices that are currently being explored.\n### How do the algorithm work\n1. Start with an unvisited vertex and initiate a DFS traversal from that vertex.\n2. Assign a DFS number to the current vertex and set its low-link value to the DFS number.\n3. Push the current vertex onto the stack.\n4. Explore all the neighbors of the current vertex. If a neighbor has not been visited, recursively traverse it using DFS and update the low-link value of the current vertex if necessary.\n5. After exploring all the neighbors, if the low-link value of the current vertex is equal to its DFS number, then it is the root of an SCC. Pop vertices from the stack until the current vertex is reached, and add the popped vertices to the SCC.\n6. Repeat steps 1-5 for any unvisited vertices until all vertices have been visited.\n\nAt the end of the algorithm, the algorithm outputs the SCCs found in the graph.\n### Algorithm time complexity\nTarjan's algorithm has a same time complexity as DFS, $O(V + E)$, where $V$ is the number of vertices and $E$ is the number of edges in the graph.\n### Edges classification\nConsider there are graph as following\n```mermaid\ngraph LR\n1((1)) --\u003e 2((2))\n1((1)) --\u003e 3((3))\n1((1)) --\u003e 8((8))\n2((2)) --\u003e 4((4))\n3((3)) --\u003e 5((5))\n4((4)) --\u003e 6((6))\n5((5)) --\u003e 4((4))\n5((5)) --\u003e 7((7))\n5((5)) --\u003e 8((8))\n6((6)) --\u003e 2((2))\n```\nAnd doing DFS process from edge 1, then\n1. \u003cb\u003eTree Edge\u003c/b\u003e is an edge which is present in the tree obtained after applying DFS on the graph. In the example above, the tree edge is 1-\u003e2, 2-\u003e4, 4-\u003e6, 1-\u003e3, 3-\u003e5, 5-\u003e7, 5-\u003e8. \n2. \u003cb\u003eForward Edge\u003c/b\u003e is an edge $(u, v)$ such that $v$ is a descendant but not part of the DFS tree. In the example above, 1-\u003e8 is a forward edge. \n3. \u003cb\u003eBack edge\u003c/b\u003e is an edge $(u, v)$ such that $v$ is the ancestor of node $u$ but is not part of the DFS tree. In the example above, 6-\u003e2 is a back edge. Presence of back edge indicates a cycle in directed graph. \n4. \u003cb\u003eCross Edge\u003c/b\u003e is an edge that connects two nodes such that they do not have any ancestor and a descendant relationship between them. In the example above, 5-\u003e4 is a cross edge.\n### Tarjans Modification\nTarjans Algorithm should be simply modified to find all bridges in the graph. Bridges, also known as cut edges, are the edges in a graph whose removal increases the number of connected components. In other words, if a bridge edge is removed, the graph will become more disconnected.\n\nTo find bridges in a graph, Tarjan's algorithm could be extended by adding an additional step during the DFS traversal. Here is the detail\n1. Iterate over each neighbor $v$ of vertex $u$:\n2. If $v$ is not visited, \n   1. recursively visit it \n   2. Update ```lowLinks[u]``` with the minimum of ```lowLinks[u]``` and ```lowLinks[v]```.\n   3. If ```lowLinks[v]``` is greater than ```indices[u]``` or ```lowLinks[u]``` is greater than ```indices[v]``` (must check both due to undirected graph), it means that the edge $(u, v)$ is a bridge. Add it to the bridges list.\n3. Else if $v$ is visited and $v$ is not the parent of $u$ then update ```lowLinks[u]``` with the minimum of ```lowLinks[u]``` and ```disc[v]```.\n\n## How to Compile and Run the Program\nClone this repository from terminal with this command\n``` bash\n$ git clone https://github.com/mikeleo03/Tarjans-Algorithm-Simulation_Backend.git\n```\n### Run the application on development server\nCompile by running the following *command*\n``` bash\n$ go run main.go\n```\nIf you do it correctly, the pogram should be running on localhost:8080.\n\n## References\nhttps://en.wikipedia.org/wiki/Tarjan%27s_strongly_connected_components_algorithm\nhttps://www.baeldung.com/cs/scc-tarjans-algorithm\nhttps://www.thealgorists.com/Algo/GraphTheory/Tarjan/SCC\n\n## Contributors\n\u003ca href = \"https://github.com/mikeleo03/markdown-editor/graphs/contributors\"\u003e\n  \u003cimg src = \"https://contrib.rocks/image?repo=mikeleo03/markdown-editor\"/\u003e\n\u003c/a\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikeleo03%2Ftarjans-simulation_backend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmikeleo03%2Ftarjans-simulation_backend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikeleo03%2Ftarjans-simulation_backend/lists"}