Stenography: a quick way of writing using special signs or abbreviations
StenoGraphs.jl
lets you quickly write meta graphs. As with shorthand, it is optimized for writing quickly (by humans) but is less quickly read (by computers).
To install StenoGraphs.jl
:
import Pkg; Pkg.add("StenoGraphs")
Your first @StenoGraph
using StenoGraphs
:
using StenoGraphs
@StenoGraph a → b
a → b
By the way, typing arrows can be done quickly on Linux by using Alt Gr + I
resulting in ←
and Alt GR + I
resulting in →
. All other platforms must use \leftarrow
+ Tab
or \rightarrow
+ Tab
.
Multiple nodes on one side lead to multiple edges:
@StenoGraph [a b] → c
a → c
b → c
There are two desirable outcomes for multiple edges on both sides, either element-wise edges or cross-product. The single line arrow (→
) means element-wise and double line arrow (⇒
) means cross-product (don't tell anyone but for a single node on one side →
is converted to ⇒
for convinience).
@StenoGraph [a b] → [c d]
a → c
b → d
@StenoGraph [a b] ⇒ [c d]
a → c
a → d
b → c
b → d
Modification is done by overloading *
for types of Modifier.
Let's define a Modifier
:
struct Weight <: EdgeModifier
w::Number
end
An EdgeModifier
can be directly applied to edges:
@StenoGraph (a → b) * Weight(1)
a → b * Main.Weight(1)
Multiplying a Node
with an EdgeModifier
leads to a ModifyingNode
.
:b * Weight(1)
b * Main.Weight(1)
A ModifyingNode
will modify its edges:
@StenoGraph a → b * Weight(1)
a → b * Main.Weight(1)
To modify Nodes directly with a NodeModifier
to create a ModifiedNode
(instead of ModifyingNode
) we overload ^
:
struct NodeLabel <: NodeModifier
l
end
@StenoGraph a → b^NodeLabel("Dickes B")
a → b^Main.NodeLabel("Dickes B")
The R programming language has formulas of the form a ~ b
to specify regressions. This inspired Yves Rosseel to create a very concise, yet expressive syntax for Structural Equation Models for lavaan
. Stenographs.jl
tries to maintain the best features of this syntax while creating Julia Objects that represent a graph (i.e., similar to MetaGraphs).