Skip to content

Latest commit

 

History

History
39 lines (31 loc) · 896 Bytes

readme.md

File metadata and controls

39 lines (31 loc) · 896 Bytes

Kotlin DOT DSL

Overview

DOT is a Domain Specific Language (DSL) that is used in the Graphviz - Graph Visualization Software to describe graphs. A graph is an ensemble of nodes connected by edges.

This project aims to mimic this language using various features of the Kotlin language.

Example

This is the graph described with DOT:

graph graphname {
    yellow -- green -- red;
    green -- blue [style=dashed];
}

Using this library, we can write it in Kotlin:

val yellow = Node("yellow")
val green = Node("green")
val red = Node("red")
val blue = Node("blue")

val graph = Graph (
    yellow - green - red,
    (green - blue) [Style.DASHED],
)
print(graph)

This code prints the following graph:

(yellow) .. (green) .. (red)
(green) -- (blue)

(This graph is of course only for demonstration purpose)