{"id":16286480,"url":"https://github.com/dynesshely/prouter","last_synced_at":"2025-03-20T02:31:40.695Z","repository":{"id":209039949,"uuid":"722857825","full_name":"Dynesshely/Prouter","owner":"Dynesshely","description":"A library to visualize algorithm by tracing your code.","archived":false,"fork":false,"pushed_at":"2024-05-26T08:54:37.000Z","size":109,"stargazers_count":11,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-17T13:54:38.640Z","etag":null,"topics":["algorithm","algorithm-analysis","algorithm-visualizer","visualization"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Dynesshely.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-11-24T05:50:35.000Z","updated_at":"2024-05-26T08:54:40.000Z","dependencies_parsed_at":"2024-10-27T21:43:16.410Z","dependency_job_id":null,"html_url":"https://github.com/Dynesshely/Prouter","commit_stats":null,"previous_names":["dynesshely/prouter"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dynesshely%2FProuter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dynesshely%2FProuter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dynesshely%2FProuter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dynesshely%2FProuter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Dynesshely","download_url":"https://codeload.github.com/Dynesshely/Prouter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244538590,"owners_count":20468745,"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","algorithm-analysis","algorithm-visualizer","visualization"],"created_at":"2024-10-10T19:43:13.568Z","updated_at":"2025-03-20T02:31:40.298Z","avatar_url":"https://github.com/Dynesshely.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# About\n\nProuter is a library that allows you to trace your code and visualize your algorithm.\n\n# Usages\n\n## Includes\n\n```c++\n#include \u003cprouter/includes.h\u003e\n```\n\nand you'd better include `predefine.h` after main function like this:\n\n```c++\n#include \u003cprouter/includes.h\u003e\n\nint main() {\n\n#include \u003cprouter/predefine.h\u003e\n......\n```\n\n## Trace a var\n\n```c++\ndouble a = 3.0;\na = 4.0, a *= 2.0;\n\nstd::cout \u003c\u003c a.history() \u003c\u003c std::endl \u003c\u003c std::endl;\n```\n\nOutput:\n\n```text\n3.000000 -\u003e 4.000000 -\u003e 8.000000\n```\n\n## Trace an array\n\n```c++\nauto int_arrTracer = prouter::traceArray().named(\"int arr tracer\");\n\nint intarr[10] = {0};\n\nint_arrTracer.trace(intarr, 10);\n\nfor (int i = 0; i \u003c 10; ++i) intarr[i] = i;\n\nint_arrTracer.printTo(std::cout, true).dispose();\n\n\nauto num_arrTracer = prouter::traceArray().named(\"num arr tracer\");\n\ndouble numarr[10] = {0};\n\nnum_arrTracer.trace(numarr, 10);\n\nfor (int i = 0; i \u003c 10; ++i) numarr[i] = i;\n\nstd::cout \u003c\u003c num_arrTracer.history() \u003c\u003c std::endl;\n\nnum_arrTracer.dispose(numarr);\n```\n\nOutput:\n\n```text\n╔════════════════════════════════╗\n║         int arr tracer         ║\n╠════════════════════════════════╣\n║ [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] ║\n╠════════════════════════════════╣\n║ [0, 1, 0, 0, 0, 0, 0, 0, 0, 0] ║\n╠════════════════════════════════╣\n║ [0, 1, 2, 0, 0, 0, 0, 0, 0, 0] ║\n╠════════════════════════════════╣\n║ [0, 1, 2, 3, 0, 0, 0, 0, 0, 0] ║\n╠════════════════════════════════╣\n║ [0, 1, 2, 3, 4, 0, 0, 0, 0, 0] ║\n╠════════════════════════════════╣\n║ [0, 1, 2, 3, 4, 5, 0, 0, 0, 0] ║\n╠════════════════════════════════╣\n║ [0, 1, 2, 3, 4, 5, 6, 0, 0, 0] ║\n╠════════════════════════════════╣\n║ [0, 1, 2, 3, 4, 5, 6, 7, 0, 0] ║\n╠════════════════════════════════╣\n║ [0, 1, 2, 3, 4, 5, 6, 7, 8, 0] ║\n╠════════════════════════════════╣\n║ [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] ║\n╚════════════════════════════════╝\n\n[0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000]\n[0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000]\n[0.000000, 1.000000, 2.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000]\n[0.000000, 1.000000, 2.000000, 3.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000]\n[0.000000, 1.000000, 2.000000, 3.000000, 4.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000]\n[0.000000, 1.000000, 2.000000, 3.000000, 4.000000, 5.000000, 0.000000, 0.000000, 0.000000, 0.000000]\n[0.000000, 1.000000, 2.000000, 3.000000, 4.000000, 5.000000, 6.000000, 0.000000, 0.000000, 0.000000]\n[0.000000, 1.000000, 2.000000, 3.000000, 4.000000, 5.000000, 6.000000, 7.000000, 0.000000, 0.000000]\n[0.000000, 1.000000, 2.000000, 3.000000, 4.000000, 5.000000, 6.000000, 7.000000, 8.000000, 0.000000]\n[0.000000, 1.000000, 2.000000, 3.000000, 4.000000, 5.000000, 6.000000, 7.000000, 8.000000, 9.000000]\n```\n\n## Trace a loop\n\n```c++\nauto loopTracer = prouter::traceLoop().named(\"loop 1\");\n\nint f[13], i = 1, fc;\nf[1] = 1, f[2] = 1;\n\nloopTracer.trace(\u0026i.named(\"i\"))\n          .trace(\u0026fc.named(\"fc\"))\n          .trace(f, 13, 2);\n\nfor (; i \u003c= 10; ++i, loopTracer.loop()) {\n    if (i \u003e= 3)\n        f[i] = f[i - 1] + f[i - 2];\n    fc.setValue(f[i]);\n}\n\nloopTracer.end().printTo(std::cout);\n```\n\nOutput:\n\n```text\n╔═══╦══════════╦══════════╦═════════════════════════════════════════════╗\n║   ║ i        ║ fc       ║ default array tracer                        ║\n╠═══╬══════════╬══════════╬═════════════════════════════════════════════╣\n║ 0 ║ 1 -\u003e 2   ║ 0 -\u003e 1   ║ [0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]     ║\n╠═══╬══════════╬══════════╬═════════════════════════════════════════════╣\n║ 1 ║ 2 -\u003e 3   ║ 1 -\u003e 1   ║ [0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]     ║\n╠═══╬══════════╬══════════╬═════════════════════════════════════════════╣\n║ 2 ║ 3 -\u003e 4   ║ 1 -\u003e 2   ║ [0, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0]     ║\n╠═══╬══════════╬══════════╬═════════════════════════════════════════════╣\n║ 3 ║ 4 -\u003e 5   ║ 2 -\u003e 3   ║ [0, 1, 1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0]     ║\n╠═══╬══════════╬══════════╬═════════════════════════════════════════════╣\n║ 4 ║ 5 -\u003e 6   ║ 3 -\u003e 5   ║ [0, 1, 1, 2, 3, 5, 0, 0, 0, 0, 0, 0, 0]     ║\n╠═══╬══════════╬══════════╬═════════════════════════════════════════════╣\n║ 5 ║ 6 -\u003e 7   ║ 5 -\u003e 8   ║ [0, 1, 1, 2, 3, 5, 8, 0, 0, 0, 0, 0, 0]     ║\n╠═══╬══════════╬══════════╬═════════════════════════════════════════════╣\n║ 6 ║ 7 -\u003e 8   ║ 8 -\u003e 13  ║ [0, 1, 1, 2, 3, 5, 8, 13, 0, 0, 0, 0, 0]    ║\n╠═══╬══════════╬══════════╬═════════════════════════════════════════════╣\n║ 7 ║ 8 -\u003e 9   ║ 13 -\u003e 21 ║ [0, 1, 1, 2, 3, 5, 8, 13, 21, 0, 0, 0, 0]   ║\n╠═══╬══════════╬══════════╬═════════════════════════════════════════════╣\n║ 8 ║ 9 -\u003e 10  ║ 21 -\u003e 34 ║ [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 0, 0, 0]  ║\n╠═══╬══════════╬══════════╬═════════════════════════════════════════════╣\n║ 9 ║ 10 -\u003e 11 ║ 34 -\u003e 55 ║ [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 0, 0] ║\n╚═══╩══════════╩══════════╩═════════════════════════════════════════════╝\n```\n\n## Trace a stack\n\n```c++\nauto pstackTest = (new stack\u003cs_int\u003e())-\u003epush(4)\n                                      .push(8)\n                                      .push(2)\n                                      .pop()\n                                      .push(9)\n                                      .pop()\n                                      .push(3)\n                                      .pop()\n                                      .push(1)\n                                      .pop()\n                                      .clear()\n                                      .printHistoryTo(std::cout);\n```\n\n\u003e Here use `s_int` to avoid using `pint`\n\nOutput:\n\n```text\n                                                                                                                                                                     \n                                                                                                                                                                     \n                                +---+                           +---+                           +---+                           +---+                                \n                                |   |                           |   |                           |   |                           |   |                                \n                +---+           +---+           +---+           +---+           +---+           +---+           +---+           +---+           +---+                \n         --\u003e    |   |    --\u003e    | 2 |    --\u003e    |   |    --\u003e    | 9 |    --\u003e    |   |    --\u003e    | 3 |    --\u003e    |   |    --\u003e    | 1 |    --\u003e    |   |    --\u003e         \n+---+           +---+           +---+           +---+           +---+           +---+           +---+           +---+           +---+           +---+                \n|   |           | 8 |           | 8 |           | 8 |           | 8 |           | 8 |           | 8 |           | 8 |           | 8 |           | 8 |                \n+---+           +---+           +---+           +---+           +---+           +---+           +---+           +---+           +---+           +---+           +---+\n| 4 |           | 4 |           | 4 |           | 4 |           | 4 |           | 4 |           | 4 |           | 4 |           | 4 |           | 4 |           |   |\n+---+           +---+           +---+           +---+           +---+           +---+           +---+           +---+           +---+           +---+           +---+\n```\n\n## Trace a queue\n\n```c++\nauto pqueueTest = (new queue\u003cint\u003e())-\u003epush(3)\n                                    .push(7)\n                                    .pop()\n                                    .push(16)\n                                    .pop()\n                                    .push(12)\n                                    .push(244)\n                                    .push(9)\n                                    .pop()\n                                    .pop()\n                                    .clear()\n                                    .printHistoryTo(std::cout);\n```\n\nOutput:\n\n```text\n               +----+---+----+         \n   0           | \u003c- | 3 | \u003c- |         \n               +----+---+----+         \n             +----+---+---+----+       \n   1         | \u003c- | 3 | 7 | \u003c- |       \n             +----+---+---+----+       \n               +----+---+----+         \n   2           | \u003c- | 7 | \u003c- |         \n               +----+---+----+         \n             +----+---+----+----+      \n   3         | \u003c- | 7 | 16 | \u003c- |      \n             +----+---+----+----+      \n               +----+----+----+        \n   4           | \u003c- | 16 | \u003c- |        \n               +----+----+----+        \n            +----+----+----+----+      \n   5        | \u003c- | 16 | 12 | \u003c- |      \n            +----+----+----+----+      \n         +----+----+----+-----+----+   \n   6     | \u003c- | 16 | 12 | 244 | \u003c- |   \n         +----+----+----+-----+----+   \n       +----+----+----+-----+---+----+ \n   7   | \u003c- | 16 | 12 | 244 | 9 | \u003c- | \n       +----+----+----+-----+---+----+ \n          +----+----+-----+---+----+   \n   8      | \u003c- | 12 | 244 | 9 | \u003c- |   \n          +----+----+-----+---+----+   \n            +----+-----+---+----+      \n   9        | \u003c- | 244 | 9 | \u003c- |      \n            +----+-----+---+----+      \n         +----+---------------+----+   \n  10     | \u003c- | \u003cempty queue\u003e | \u003c- |   \n         +----+---------------+----+\n```\n\n## Trace Algorithms\n\n### LCS (Longest Common Sequence)\n\n```c++\nauto lcs = (new alg_lcs())-\u003esetValue(\n    \"ABCBDAB\",\n    \"BDCABA\"\n).run().printLcsTo(std::cout);\n```\n\nOutput:\n\n```text\n+-----------------------------+\n|   Longest Common Sequence   |\n+-----------------------------+\n|  -  -  A  B  C  B  D  A  B  |\n|  -  0  0  0  0  0  0  0  0  |\n|  B  0  0  1  1  1  1  1  1  |\n|  D  0  0  1  1  1  2  2  2  |\n|  C  0  0  1  2  2  2  2  2  |\n|  A  0  1  1  2  2  2  3  3  |\n|  B  0  1  2  2  3  3  3  4  |\n|  A  0  1  2  2  3  3  4  4  |\n+-----------------------------+\n| len: 4                      |\n+-----------------------------+\n| lcs: BCBA                   |\n+-----------------------------+\n| lcs: BDAB                   |\n+-----------------------------+\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdynesshely%2Fprouter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdynesshely%2Fprouter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdynesshely%2Fprouter/lists"}