Kale Graph

approved

by Oli

Render mathematical graphs.

7 stars602 downloadsUpdated 10mo agoMIT
View on GitHub

Kale Graph GitHub Release

Kale Graph is an Obsidian plugin making it easy to visualize graphs (the Graph theory kind).

Getting started is as simple as installing the plugin and making a new code block, specifying kale as the language.

kale language/format

Kale code blocks are parsed line by line. A line can specify flags, add vertices or add edges. A line cannot do multiple of these at the same time.

Flags

Kale code blocks can specify flags that change how the code block is parsed/rendered. If the first line of a code block starts with a hyphen - any letter on the rest of the line will be treated as a flag and apply changes as specified below.

List of all flags

FlagNameDescription
dDirectedMakes the graph directed
sSimpleRemoves repeated edges
aAutoAdds missing vertices that edges are connected to
fFlippedFlips the rows and columns of an adjacency matrix

Vertices

A vertex is specified simply by a name that identifies that vertex. Vertex names may contain any character that is not a control character or used as part of Kale syntax. Multiple vertices can be defined on a single line using the following syntax (spaces are optional):

vertex 1, vertex 2, vertex 3

If a vertex is defined more than once the later definitions are silently ignored.

[!TIP]
Any vertex that starts with an underscore (_) will be treated as an invisible vertex, meaning it is not rendered but still offsets other vertices. Useful for making subgraphs where you want the shaape to stay the same but not contain all vertices. Unlike normal vertices, invisible vertices names do not have to be unique.

Edges

An edge is a connection between two vertices. An edge is specified by two vertices surrounded by parenthesis () and seperated by a comma ,. If the Directed flag is active the edge will point from the first vertex to the second.

a,b,c
(a,b), (b,c) // An edge from a to b, and one from b to c

Paths

Several edges in sequence can be specified as a path, which is represented as multiple vertices seperated by a connector -.

a,b,c,d,e,f
(a,b),(b,c),(c,d),(d,e),(e,f) // Long and tedious definition of every edge
a-b-c-d-e-f // Shorter path definition

Paths are also an easy way to define cycles:

a,b,c
a-b-c-a // A cycle from a to a

Adjacency matrix

Edges can also be represented as an adjacency matrix, the syntax is shown below. Adjacency matrices can be flipped with the Flipped flag.

a,b,c
0 1 0 // Spaces are optional for single digits
1 0 0
0 0 2

[!NOTE] An adjacency matrix cannot be combined with other ways of defining edges and will give an error.

Comments

Any text after // will be treated as a comment and ignored when parsing a code block.

Settings

The appearance of Kale code blocks can be customized in the plugin's settings.

For plugin developers

Search results and similarity scores are powered by semantic analysis of your plugin's README. If your plugin isn't appearing for searches you'd expect, try updating your README to clearly describe your plugin's purpose, features, and use cases.