Typed, bounded GraphML graph interchange for MoonBit
moon add FikaRomantic/moongraphml@0.1.0moon update
moon check --target all --deny-warn
moon build --target all --deny-warn
moon test --target all --deny-warnpwsh -NoProfile -File scripts/Invoke-Moon016.ps1 check --target all --deny-warn --frozen
pwsh -NoProfile -File scripts/Invoke-Moon016.ps1 build --target all --deny-warn --frozen
pwsh -NoProfile -File scripts/Invoke-Moon016.ps1 test --target all --deny-warn --frozen
pwsh -NoProfile -File scripts/Invoke-Moon016.ps1 fmtmoon run --target native --deny-warn examples/dependencies
moon run --target native --deny-warn examples/topology
moon run --target native --deny-warn examples/datasets
moon run --target native --deny-warn examples/analyticsimport {
"FikaRomantic/moongraphml" @graphml,
}fn main raise {
let builder = try! @graphml.FlatBuilder::new([], @graphml.Directed)
try! builder.add_node("api")
try! builder.add_node("database")
try! builder.add_edge("api", "database", id="uses")
let document = try! builder.finish()
let xml = try! @graphml.serialize(document)
assert_true(document.equivalent(try! @graphml.parse(xml)))
println(xml)
}let flat = try! document.flat_graph(@graphml.GraphAddress::root(0))
let selected = try! flat.induced_subgraph(["api", "database"])
let selected_flat = try! selected.flat_graph(@graphml.GraphAddress::root(0))
let csr = try! selected_flat.to_csr(orientation=@graphml.Incoming)
let database = csr.node_index("database").unwrap()
let dependencies = try! csr.row(database)moon run --target native --deny-warn cmd/graphml -- inspect tests/fixtures/flat.graphml
moon run --target native --deny-warn cmd/graphml -- verify tests/fixtures/flat.graphml
moon run --target native --deny-warn cmd/graphml -- roundtrip tests/fixtures/flat.graphml
moon run --target native --deny-warn cmd/graphml -- roundtrip-compatible tests/fixtures/flat.graphml
moon run --target native --deny-warn cmd/graphml -- generate 7
moon run --target native --deny-warn cmd/graphml -- subgraph tests/fixtures/flat.graphml a b
moon run --target native --deny-warn cmd/graphml -- csr tests/fixtures/flat.graphml
moon run --target native --deny-warn cmd/graphml -- csr-incoming tests/fixtures/flat.graphmlpub struct Attributes {
// private fields
}fn Attributes::get(self : Attributes, id : String, use_default? : Bool) -> DataValue? raise GraphErrorfn Attributes::new(doc : Document, scope : Scope, data : Array[Datum], limits? : Limits) -> Attributes raise GraphErrorfn Attributes::scalar(self : Attributes, id : String, use_default? : Bool) -> Scalar? raise GraphErrorpub struct CountHint {
// private fields
}pub struct CsrAdjacency {
// private fields
}pub(all) struct Datum {
key : String
id : String?
value : DataValue
extra : Array[XmlAttributeValue]
namespaces : Array[NamespaceBinding]
}pub struct Document {
// private fields
}fn Document::merge(self : Document, other : Document, prefix : String, limits? : Limits) -> MergeResult raise GraphErrorfn Document::new(keys : Array[Key], graphs : Array[Graph], data? : Array[Datum], description? : String, extra? : Array[XmlAttributeValue], namespaces? : Array[NamespaceBinding], limits? : Limits) -> Document raise GraphErrorfn Document::remove_key(self : Document, id : String, limits? : Limits) -> Document raise GraphErrorfn Document::rename_key(self : Document, old_id : String, new_id : String, limits? : Limits) -> Document raise GraphErrorfn Document::rename_node(self : Document, root : Int, old_id : String, new_id : String, limits? : Limits) -> Document raise GraphErrorfn Document::rename_port(self : Document, root : Int, node_id : String, old_name : String, new_name : String, limits? : Limits) -> Document raise GraphErrorfn Document::replace_edge(self : Document, address : ElementAddress, edge : Edge, limits? : Limits) -> Document raise GraphErrorfn Document::replace_graph(self : Document, address : GraphAddress, replacement : Graph, limits? : Limits) -> Document raise GraphErrorfn Document::replace_node(self : Document, address : ElementAddress, node : Node, limits? : Limits) -> Document raise GraphErrorpub(all) struct Edge {
id : String?
source : String
target : String
source_port : String?
target_port : String?
directed : Bool?
description : String?
data : Array[Datum]
graph : Graph?
extra : Array[XmlAttributeValue]
namespaces : Array[NamespaceBinding]
}pub(all) struct Endpoint {
id : String?
node : String
port : String?
kind : EndpointKind
description : String?
extra : Array[XmlAttributeValue]
namespaces : Array[NamespaceBinding]
}pub struct FlatBuilder {
// private fields
}fn FlatBuilder::add_edge(self : FlatBuilder, source : String, target : String, id? : String, directed? : Bool, attributes? : Array[(String, Scalar)], description? : String) -> Unit raise GraphErrorfn FlatBuilder::add_node(self : FlatBuilder, id : String, attributes? : Array[(String, Scalar)], description? : String) -> Unit raise GraphErrorfn FlatBuilder::new(keys : Array[Key], direction : Direction, graph_id? : String, description? : String, limits? : Limits) -> FlatBuilder raise GraphErrorfn FlatBuilder::set_graph_data(self : FlatBuilder, attributes : Array[(String, Scalar)]) -> Unit raise GraphErrorpub struct FlatGraph {
// private fields
}fn FlatGraph::to_csr(self : FlatGraph, orientation? : CsrOrientation, max_arcs? : Int) -> CsrAdjacency raise GraphErrorpub struct GraphIndex {
// private fields
}fn GraphIndex::incident_edges(self : GraphIndex, root : Int, node : String) -> Array[ElementAddress]fn GraphIndex::incident_hyperedges(self : GraphIndex, root : Int, node : String) -> Array[ElementAddress]pub(all) struct Hyperedge {
id : String?
description : String?
data : Array[Datum]
endpoints : Array[Endpoint]
graph : Graph?
extra : Array[XmlAttributeValue]
namespaces : Array[NamespaceBinding]
}pub(all) struct Key {
id : String
scope : Scope
name : String?
value_type : ValueType?
default_value : DataValue?
default_extra : Array[XmlAttributeValue]
default_namespaces : Array[NamespaceBinding]
description : String?
extra : Array[XmlAttributeValue]
namespaces : Array[NamespaceBinding]
}pub(all) struct Locator {
href : String
link_type : String?
extra : Array[XmlAttributeValue]
namespaces : Array[NamespaceBinding]
}pub(all) struct NamespaceBinding {
prefix : String?
namespace_uri : String
}pub(all) struct Node {
id : String
description : String?
data : Array[Datum]
ports : Array[Port]
graph : Graph?
locator : Locator?
extra : Array[XmlAttributeValue]
namespaces : Array[NamespaceBinding]
}pub(all) struct Port {
name : String
description : String?
data : Array[Datum]
ports : Array[Port]
extra : Array[XmlAttributeValue]
namespaces : Array[NamespaceBinding]
}pub(all) enum Scalar {
BooleanValue(Bool)
IntegerValue(Int)
LongValue(Int64)
FloatValue(Float)
DoubleValue(Double)
TextValue(String)
} derive(Debug)pub(all) struct Statistics {
keys : Int
graphs : Int
nodes : Int
edges : Int
hyperedges : Int
endpoints : Int
ports : Int
data_entries : Int
max_graph_depth : Int
has_mixed_direction : Bool
has_parallel_edges : Bool
has_self_loops : Bool
has_locators : Bool
has_xml_payloads : Bool
} derive(Eq, Debug)pub(all) struct XmlAttributeValue {
namespace_uri : String?
name : String
value : String
}pub(all) struct XmlElementValue {
namespace_uri : String?
name : String
prefix : String?
namespaces : Array[NamespaceBinding]
attributes : Array[XmlAttributeValue]
content : Array[XmlValue]
}Install
Download zipTyped, bounded GraphML graph interchange for MoonBit