Graphic (graphic v0.1.3)

Copy Markdown

Build directed graphs, query them, and compile into common diagramming languages.

iex> alias Graphic, as: G
iex> G.new() |> G.bridge("a", "b") |> G.edges()
[
  {"a", "b", []}
]

Edges can also be assigned a label.

iex> alias Graphic, as: G
iex> G.new() |> G.bridge("a", "b", "broken!") |> G.edges()
[
  {"a", "b", "broken!"}
]

Summary

Functions

render graph as a d2 diagram. See https://d2lang.com

add a plain edge, and any missing nodes.

add a labeled edge, and any missing nodes.

query all edges in graph.

query all edges from a node.

describe neighboring nodes.

Functions

as_d2(g)

(since 0.1.2)

render graph as a d2 diagram. See https://d2lang.com

iex>alias Graphic, as: G
iex> G.new()
...> |>G.bridge("a", "b")
...> |>G.bridge("a", "c")
...> |>G.bridge("c", "d", "broken!")
...> |>G.bridge("b", "d")
...> |>G.as_d2()
"""
a -> b
a -> c
c -> d: 'broken!'
b -> d
"""

bridge(g, a, b)

(since 0.1.2)

add a plain edge, and any missing nodes.

bridge(g, a, b, label)

(since 0.1.2)

add a labeled edge, and any missing nodes.

edges(g)

(since 0.1.2)

query all edges in graph.

edges(g, n)

(since 0.1.2)

query all edges from a node.

neighbors(g, n)

(since 0.1.2)

describe neighboring nodes.

new()

(since 0.1.2)