moon_dagre

Dagre layout engine implemented in MoonBit

layout
moon add moonbit-community/moon_dagre@0.3.1
Download zip
Version
0.3.1
License
Apache-2.0
Last updated
last month
Downloads
13K
README

#moonbit-community/moon_dagre

A MoonBit port of the dagre graph layout engine.

#Install

moon add moonbit-community/moon_dagre

#Basic Usage

moon.pkg:
import { "moonbit-community/moon_dagre" @dagre, }

main.mbt:
///|
fn main {
let g = dagre.new_graph(directed=true, multigraph=true, compound=true)
g.set_node(
"a",
label=dagre
.empty_attrs()
.tap(n => {
n.set_float("width", 80.0)
n.set_float("height", 40.0)
}),
)
g.set_node(
"b",
label=dagre
.empty_attrs()
.tap(n => {
n.set_float("width", 80.0)
n.set_float("height", 40.0)
}),
)
g.set_edge("a", "b", label=dagre.attrs_value(dagre.empty_attrs()))

dagre.layout(g)

// Read computed coordinates from node labels:
// g.node("a").get_float("x"), g.node("a").get_float("y"), ...
}

#API

  • Entry points:
    • dagre.new_graph(...)
    • dagre.layout(g)
  • Version:
    • dagre.version()

For full exported symbols, check pkg.generated.mbti.

#
edge_obj

fn edge_obj(v : String, w : String, name? : String) ->
EdgeObj

#
new_graph

fn new_graph(directed? : Bool, multigraph? : Bool, compound? : Bool) ->
Graph

#
point

fn point(x : Double, y : Double) ->
Point

#
value_as_bool

fn value_as_bool(value :
Value
?) -> Bool?

#
value_as_float

fn value_as_float(value :
Value
?) -> Double?

#
value_as_int

fn value_as_int(value :
Value
?) -> Int?

#
value_as_string

fn value_as_string(value :
Value
?) -> String?

#
value_bool

#
value_float

#
value_string

#
version

fn version() -> String

Powered by MoonBit

Site sourceReport issuePackagesBuild queueSkillsStatistics

© 2026 mooncakes.io