https://github.com/aaronpeikert/stenographs.jl
Write meta graphs quickly
https://github.com/aaronpeikert/stenographs.jl
graphs julialang neural-networks structural-equation-modeling
Last synced: about 1 month ago
JSON representation
Write meta graphs quickly
- Host: GitHub
- URL: https://github.com/aaronpeikert/stenographs.jl
- Owner: aaronpeikert
- License: mit
- Created: 2022-01-21T10:23:19.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-02-13T12:21:00.000Z (3 months ago)
- Last Synced: 2025-04-13T03:55:45.082Z (about 1 month ago)
- Topics: graphs, julialang, neural-networks, structural-equation-modeling
- Language: Julia
- Homepage: https://aaronpeikert.github.io/StenoGraphs.jl/
- Size: 601 KB
- Stars: 5
- Watchers: 2
- Forks: 3
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- Changelog: changelog.md
- License: LICENSE
Awesome Lists containing this project
README
# StenoGraphs.jl ― A concise language to write meta graphs
[](https://aaronpeikert.github.io/StenoGraphs.jl/dev) [](https://github.com/aaronpeikert/StenoGraphs.jl/actions/workflows/CI.yml?query=branch%3Amain) [](https://codecov.io/gh/aaronpeikert/StenoGraphs.jl)
> **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`:
```julia
import Pkg; Pkg.add("StenoGraphs")
```Your first `@StenoGraph` using `StenoGraphs`:
```julia
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
Multiple nodes on one side lead to multiple edges:
```julia
@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).
```julia
@StenoGraph [a b] → [c d]
``````
a → c
b → d```
```julia
@StenoGraph [a b] ⇒ [c d]
``````
a → c
a → d
b → c
b → d```
## Modification
Modification is done by overloading `*` for types of Modifier.
Let's define a `Modifier`:
```julia
struct Weight <: EdgeModifier
w::Number
end
```An `EdgeModifier` can be directly applied to edges:
```julia
@StenoGraph (a → b) * Weight(1)
``````
a → b * Main.Weight(1)```
Multiplying a `Node` with an `EdgeModifier` leads to a `ModifyingNode`.
```julia
:b * Weight(1)
``````
b * Main.Weight(1)
```A `ModifyingNode` will modify its edges:
```julia
@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 `^`:
```julia
struct NodeLabel <: NodeModifier
l
end@StenoGraph a → b^NodeLabel("Dickes B")
``````
a → b^Main.NodeLabel("Dickes B")```
## Related Software
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`](https://lavaan.ugent.be/tutorial/syntax1.html). `Stenographs.jl` tries to maintain the best features of this syntax while creating Julia Objects that represent a graph (i.e., similar to [MetaGraphs](https://github.com/JuliaGraphs/MetaGraphs.jl)).