{"id":13941200,"url":"https://github.com/mdr/ascii-graphs","last_synced_at":"2025-07-20T04:30:51.837Z","repository":{"id":3595984,"uuid":"4660060","full_name":"mdr/ascii-graphs","owner":"mdr","description":"Parse ASCII art diagrams of graphs (nodes and edges)","archived":false,"fork":false,"pushed_at":"2018-10-09T09:08:19.000Z","size":377,"stargazers_count":173,"open_issues_count":6,"forks_count":37,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-05-23T04:48:47.850Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Scala","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/mdr.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-06-14T06:28:14.000Z","updated_at":"2024-03-09T23:07:17.000Z","dependencies_parsed_at":"2022-08-06T14:01:18.695Z","dependency_job_id":null,"html_url":"https://github.com/mdr/ascii-graphs","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/mdr/ascii-graphs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdr%2Fascii-graphs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdr%2Fascii-graphs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdr%2Fascii-graphs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdr%2Fascii-graphs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mdr","download_url":"https://codeload.github.com/mdr/ascii-graphs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdr%2Fascii-graphs/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266067255,"owners_count":23871324,"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":[],"created_at":"2024-08-08T02:01:13.917Z","updated_at":"2025-07-20T04:30:51.520Z","avatar_url":"https://github.com/mdr.png","language":"Scala","funding_links":[],"categories":["Scala"],"sub_categories":[],"readme":"An ASCII-art diagram library for graphs. It supports both parsing existing diagrams and rendering graphs out as an ASCII diagram.\n\nYou can use it via sbt:\n\n    libraryDependencies += \"com.github.mdr\" %% \"ascii-graphs\" % \"0.0.3\"\n\n# Graph layout\n\n    import com.github.mdr.ascii.layout._\n\n    val graph = Graph(\n      vertices = List(\n        \"V1\", \"V2\", \"V3\", \"V4\", \"V5\", \"V6\", \"V7\"),\n      edges = List(\n        \"V1\" -\u003e \"V2\",\n        \"V7\" -\u003e \"V1\",\n        \"V1\" -\u003e \"V3\",\n        \"V1\" -\u003e \"V4\",\n        \"V2\" -\u003e \"V5\",\n        \"V2\" -\u003e \"V6\"))\n\n    val ascii = Layouter.renderGraph(graph)\n\n    println(ascii)\n\nThis would produce:\n\n             +---+         \n             |V7 |         \n             +---+         \n               |           \n               v           \n           +-------+       \n           |  V1   |       \n           +-------+       \n             |  ||         \n         -----  |--------  \n         |      ---     |  \n         v        |     |  \n      +-----+     |     |  \n      | V2  |     |     |  \n      +-----+     |     |  \n        | |       |     |  \n      --- ---     |     |  \n      |     |     |     |  \n      v     v     v     v  \n    +---+ +---+ +---+ +---+\n    |V5 | |V6 | |V4 | |V3 |\n    +---+ +---+ +---+ +---+\n\nLayout is Sugiyama-style layered graph drawing, and supports multi-edges, cycles, and vertex labels, but not self-loops or edge labels.\n\n## Other ASCII layout libraries\n\n* Vijual (Clojure): http://lisperati.com/vijual/\n* Graph::Easy (Perl): http://bloodgate.com/perl/graph/manual/\n\n# Graph parser\n\nThe graph parser is intended for constructing test DSLs, particularly for data which would be much more comprehensible in ASCII art\nthan constructed through regular programming language expressions. For example, directed graphs, trees, 2D games, \nobject graphs, and so on.\n\nTypical usage is to parse the diagram into `Diagram`/`Box`/`Edge` objects, and then convert those objects into \nwhatever your specific test data happens to be.\n\n## Syntax\n\n### Boxes\n\n\nA `Box` is drawn as follows:\n\n    +------+\n    |      |\n    |      |\n    |      |\n    +------+\n    \nIt can contain text:\n\n    +---------------+\n    |The quick brown|\n    |fox jumps over |\n    |the lazy dog.  |\n    +---------------+\n    \nOr other boxes:\n\n    +-----+\n    |+---+|\n    ||+-+||\n    ||| |||\n    ||+-+||\n    |+---+|\n    +-----+\n\n### Edges\n\nAn `Edge` connects two boxes:\n\n    +-----+\n    |     |\n    |     |---------\n    |     |        |\n    +-----+        |\n       |           |\n       |           |\n    +-----+     +-----+\n    |     |     |     |\n    |     |-----|     |\n    |     |     |     |\n    +-----+     +-----+\n\nEdges can have an arrow at either or both ends:\n\n    +-----+\n    |     |\n    |     |---------\n    |     |        |\n    +-----+        |\n       ^           |\n       |           v\n    +-----+     +-----+\n    |     |     |     |\n    |     |\u003c---\u003e|     |\n    |     |     |     |\n    +-----+     +-----+\n\nYou can connect a child box to its parent:\n\n    +--------------+\n    |              |\n    |   +-----+    |\n    |   |     |    |\n    |   |     |----|\n    |   +-----+    |\n    |              |\n    +--------------+   \n    \nEdges can cross using a `+`:\n\n             +-----+\n             |     |\n             |     |\n             |     |\n             +-----+\n                |\n    +-----+     |     +-----+\n    |     |     |     |     |\n    |     |-----+----\u003e|     |\n    |     |     |     |     |\n    +-----+     |     +-----+\n                v\n             +-----+\n             |     |\n             |     |\n             |     |\n             +-----+    \n\n### Labels\n\nEdges can have an associated label:\n\n    +-----+\n    |     |\n    |     |\n    |     |\n    +-----+\n       |\n       |[label]\n       |\n    +-----+         +-----+\n    |     | [label] |     |\n    |     |---------|     |\n    |     |         |     |\n    +-----+         +-----+\n    \nThe label's `[` or `]` bracket must be adjacent (horizontally or vertically) to part of the edge.\n\n## Usage\n\n    import com.github.mdr.ascii._\n    \n    val diagram = Diagram(\"\"\"\n                 +-+             \n        ---------|E|----------   \n        |        +-+         |   \n     [9]|                 [6]|   \n        |                    |   \n       +-+  [2]  +-+  [11]  +-+  \n       |F|-------|C|--------|D|  \n       +-+       +-+        +-+  \n        |         |          |   \n    [14]|     [10]|      [15]|   \n        |         |          |   \n       +-+       +-+         |   \n       |A|-------|B|----------   \n       +-+  [7]  +-+      \"\"\")\n  \n    // Print all the vertices neighbouring A along with the edge weight:\n    for {\n      box ← diagram.allBoxes.find(_.text == \"A\")\n      (edge, otherBox) ← box.connections()\n      label ← edge.label\n    } println(box + \" ==\u003e \" + label + \" ==\u003e \" + otherBox)\n  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmdr%2Fascii-graphs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmdr%2Fascii-graphs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmdr%2Fascii-graphs/lists"}