@graphty/graph-io 0.3.43 → 0.3.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/approximations-DJMHdDvv.js +40 -0
- package/dist/chunks/approximations-DJMHdDvv.js.map +1 -0
- package/dist/chunks/block-CPCHkX42.js +2777 -0
- package/dist/chunks/block-CPCHkX42.js.map +1 -0
- package/dist/chunks/{choose-DvpbdRuz.js → choose--jM0yYCo.js} +3 -2
- package/dist/chunks/{choose-DvpbdRuz.js.map → choose--jM0yYCo.js.map} +1 -1
- package/dist/chunks/{constants-fT3E8JYY.js → constants-BKwqelYD.js} +6 -2
- package/dist/chunks/constants-BKwqelYD.js.map +1 -0
- package/dist/chunks/convert-BcQ8_jMo.js +59 -0
- package/dist/chunks/convert-BcQ8_jMo.js.map +1 -0
- package/dist/chunks/emit-DZy6JgdA.js +3456 -0
- package/dist/chunks/emit-DZy6JgdA.js.map +1 -0
- package/dist/chunks/{escape-B62ZGM_a.js → escape-CgzxiYPg.js} +44 -21
- package/dist/chunks/escape-CgzxiYPg.js.map +1 -0
- package/dist/chunks/{export-rKLeGQMo.js → export-BvqAXCKh.js} +196 -792
- package/dist/chunks/export-BvqAXCKh.js.map +1 -0
- package/dist/chunks/{exporter-yLxKBvLE.js → exporter--Mk9gXCJ.js} +4 -3
- package/dist/chunks/{exporter-yLxKBvLE.js.map → exporter--Mk9gXCJ.js.map} +1 -1
- package/dist/chunks/{exporter-RVtXVetw.js → exporter-C-9cgZKa.js} +1805 -287
- package/dist/chunks/exporter-C-9cgZKa.js.map +1 -0
- package/dist/chunks/{exporter-8hLNemFk.js → exporter-DFqJhBnj.js} +133 -74
- package/dist/chunks/exporter-DFqJhBnj.js.map +1 -0
- package/dist/chunks/{exporter-BWwEuOPT.js → exporter-DteVeJki.js} +22 -12
- package/dist/chunks/exporter-DteVeJki.js.map +1 -0
- package/dist/chunks/format-BpQBx8MZ.js +676 -0
- package/dist/chunks/format-BpQBx8MZ.js.map +1 -0
- package/dist/chunks/generic-BGO71QBv.js +1347 -0
- package/dist/chunks/generic-BGO71QBv.js.map +1 -0
- package/dist/chunks/{importer-C98dpSH4.js → importer-B-9Rc1zO.js} +141 -82
- package/dist/chunks/importer-B-9Rc1zO.js.map +1 -0
- package/dist/chunks/{importer-D794XUTe.js → importer-BVVR740x.js} +31 -8
- package/dist/chunks/importer-BVVR740x.js.map +1 -0
- package/dist/chunks/{importer-WrGRZb0N.js → importer-C0AjA3Ax.js} +449 -102
- package/dist/chunks/importer-C0AjA3Ax.js.map +1 -0
- package/dist/chunks/{importer-BbNb7eNg.js → importer-C7pvJe1L.js} +1398 -129
- package/dist/chunks/importer-C7pvJe1L.js.map +1 -0
- package/dist/chunks/{importer-xZ-3suY1.js → importer-ClwoVx3O.js} +791 -135
- package/dist/chunks/importer-ClwoVx3O.js.map +1 -0
- package/dist/chunks/{importer-Ht7LNg8L.js → importer-D0sC_6bO.js} +116 -296
- package/dist/chunks/importer-D0sC_6bO.js.map +1 -0
- package/dist/chunks/{importer-Dz7tI8Sa.js → importer-EHQk1jbM.js} +617 -115
- package/dist/chunks/importer-EHQk1jbM.js.map +1 -0
- package/dist/chunks/{json-elements-DKSqpNW1.js → json-elements-DJZRZ6jd.js} +123 -32
- package/dist/chunks/json-elements-DJZRZ6jd.js.map +1 -0
- package/dist/chunks/lexicon-WMsNddyU.js +509 -0
- package/dist/chunks/lexicon-WMsNddyU.js.map +1 -0
- package/dist/chunks/{ontology-export-CtRXjg_i.js → ontology-export-G4MqRdux.js} +3 -2
- package/dist/chunks/{ontology-export-CtRXjg_i.js.map → ontology-export-G4MqRdux.js.map} +1 -1
- package/dist/chunks/{records-Cu4bxYOm.js → records-CiaWZrFH.js} +2 -2
- package/dist/chunks/{records-Cu4bxYOm.js.map → records-CiaWZrFH.js.map} +1 -1
- package/dist/chunks/styles-DvoFBKCK.js +690 -0
- package/dist/chunks/styles-DvoFBKCK.js.map +1 -0
- package/dist/chunks/styles-yed-Cz9rLBCP.js +842 -0
- package/dist/chunks/styles-yed-Cz9rLBCP.js.map +1 -0
- package/dist/chunks/styles-zNTmz5R7.js +2102 -0
- package/dist/chunks/styles-zNTmz5R7.js.map +1 -0
- package/dist/chunks/{text-DHOJXnED.js → text-CzJNFOS9.js} +2 -2
- package/dist/chunks/{text-DHOJXnED.js.map → text-CzJNFOS9.js.map} +1 -1
- package/dist/chunks/units-XMZFIFe1.js +19 -0
- package/dist/chunks/units-XMZFIFe1.js.map +1 -0
- package/dist/chunks/writer-gQ8kx99H.js +448 -0
- package/dist/chunks/writer-gQ8kx99H.js.map +1 -0
- package/dist/csv.js +5 -4
- package/dist/csv.js.map +1 -1
- package/dist/cx.js +1 -1
- package/dist/cx2.js +2 -2
- package/dist/cys.js +1 -1
- package/dist/dot.js +5 -2
- package/dist/dot.js.map +1 -1
- package/dist/gexf.js +292 -412
- package/dist/gexf.js.map +1 -1
- package/dist/gml.js +927 -74
- package/dist/gml.js.map +1 -1
- package/dist/graph-io.js +351 -236
- package/dist/graph-io.js.map +1 -1
- package/dist/graphml.js +4 -2
- package/dist/graphml.js.map +1 -1
- package/dist/json.js +1 -1
- package/dist/neo4j.js +4 -3
- package/dist/neo4j.js.map +1 -1
- package/dist/obo.js +1 -1
- package/dist/pajek.js +4 -2
- package/dist/positions.d.ts +1 -0
- package/dist/positions.js +427 -0
- package/dist/positions.js.map +1 -0
- package/dist/src/common/codes.d.ts +6 -0
- package/dist/src/common/codes.d.ts.map +1 -1
- package/dist/src/common/codes.js +6 -0
- package/dist/src/common/codes.js.map +1 -1
- package/dist/src/common/escape.d.ts.map +1 -1
- package/dist/src/common/escape.js +4 -2
- package/dist/src/common/escape.js.map +1 -1
- package/dist/src/common/export.d.ts +10 -0
- package/dist/src/common/export.d.ts.map +1 -1
- package/dist/src/common/export.js +123 -100
- package/dist/src/common/export.js.map +1 -1
- package/dist/src/common/input.d.ts.map +1 -1
- package/dist/src/common/input.js +8 -1
- package/dist/src/common/input.js.map +1 -1
- package/dist/src/common/json-elements.d.ts +12 -9
- package/dist/src/common/json-elements.d.ts.map +1 -1
- package/dist/src/common/json-elements.js +160 -37
- package/dist/src/common/json-elements.js.map +1 -1
- package/dist/src/common/notes.d.ts +42 -0
- package/dist/src/common/notes.d.ts.map +1 -0
- package/dist/src/common/notes.js +72 -0
- package/dist/src/common/notes.js.map +1 -0
- package/dist/src/common/report.d.ts +18 -0
- package/dist/src/common/report.d.ts.map +1 -1
- package/dist/src/common/report.js +36 -1
- package/dist/src/common/report.js.map +1 -1
- package/dist/src/common/units.d.ts +24 -0
- package/dist/src/common/units.d.ts.map +1 -0
- package/dist/src/common/units.js +26 -0
- package/dist/src/common/units.js.map +1 -0
- package/dist/src/common/xml.d.ts +18 -0
- package/dist/src/common/xml.d.ts.map +1 -1
- package/dist/src/common/xml.js +42 -5
- package/dist/src/common/xml.js.map +1 -1
- package/dist/src/formats/cx/exporter.d.ts +6 -0
- package/dist/src/formats/cx/exporter.d.ts.map +1 -1
- package/dist/src/formats/cx/exporter.js +71 -8
- package/dist/src/formats/cx/exporter.js.map +1 -1
- package/dist/src/formats/cx/importer.d.ts +5 -2
- package/dist/src/formats/cx/importer.d.ts.map +1 -1
- package/dist/src/formats/cx/importer.js +102 -72
- package/dist/src/formats/cx/importer.js.map +1 -1
- package/dist/src/formats/cx/styles.d.ts +102 -0
- package/dist/src/formats/cx/styles.d.ts.map +1 -0
- package/dist/src/formats/cx/styles.js +225 -0
- package/dist/src/formats/cx/styles.js.map +1 -0
- package/dist/src/formats/cx2/exporter.d.ts +5 -0
- package/dist/src/formats/cx2/exporter.d.ts.map +1 -1
- package/dist/src/formats/cx2/exporter.js +181 -71
- package/dist/src/formats/cx2/exporter.js.map +1 -1
- package/dist/src/formats/cx2/importer.d.ts +4 -1
- package/dist/src/formats/cx2/importer.d.ts.map +1 -1
- package/dist/src/formats/cx2/importer.js +19 -1
- package/dist/src/formats/cx2/importer.js.map +1 -1
- package/dist/src/formats/cx2/styles.d.ts +18 -0
- package/dist/src/formats/cx2/styles.d.ts.map +1 -0
- package/dist/src/formats/cx2/styles.js +24 -0
- package/dist/src/formats/cx2/styles.js.map +1 -0
- package/dist/src/formats/cys/constants.d.ts +2 -0
- package/dist/src/formats/cys/constants.d.ts.map +1 -1
- package/dist/src/formats/cys/constants.js +2 -0
- package/dist/src/formats/cys/constants.js.map +1 -1
- package/dist/src/formats/cys/exporter.d.ts +6 -2
- package/dist/src/formats/cys/exporter.d.ts.map +1 -1
- package/dist/src/formats/cys/exporter.js +215 -53
- package/dist/src/formats/cys/exporter.js.map +1 -1
- package/dist/src/formats/cys/importer.d.ts +2 -1
- package/dist/src/formats/cys/importer.d.ts.map +1 -1
- package/dist/src/formats/cys/importer.js +119 -6
- package/dist/src/formats/cys/importer.js.map +1 -1
- package/dist/src/formats/cys/session.d.ts +2 -0
- package/dist/src/formats/cys/session.d.ts.map +1 -1
- package/dist/src/formats/cys/session.js +5 -0
- package/dist/src/formats/cys/session.js.map +1 -1
- package/dist/src/formats/cys/styles.d.ts +38 -0
- package/dist/src/formats/cys/styles.d.ts.map +1 -0
- package/dist/src/formats/cys/styles.js +213 -0
- package/dist/src/formats/cys/styles.js.map +1 -0
- package/dist/src/formats/cys/tables.d.ts +8 -3
- package/dist/src/formats/cys/tables.d.ts.map +1 -1
- package/dist/src/formats/cys/tables.js +88 -34
- package/dist/src/formats/cys/tables.js.map +1 -1
- package/dist/src/formats/dot/exporter.d.ts +2 -0
- package/dist/src/formats/dot/exporter.d.ts.map +1 -1
- package/dist/src/formats/dot/exporter.js +195 -81
- package/dist/src/formats/dot/exporter.js.map +1 -1
- package/dist/src/formats/dot/importer.d.ts.map +1 -1
- package/dist/src/formats/dot/importer.js +100 -20
- package/dist/src/formats/dot/importer.js.map +1 -1
- package/dist/src/formats/dot/index.d.ts +1 -0
- package/dist/src/formats/dot/index.d.ts.map +1 -1
- package/dist/src/formats/dot/index.js +1 -0
- package/dist/src/formats/dot/index.js.map +1 -1
- package/dist/src/formats/dot/positions.d.ts +14 -0
- package/dist/src/formats/dot/positions.d.ts.map +1 -0
- package/dist/src/formats/dot/positions.js +70 -0
- package/dist/src/formats/dot/positions.js.map +1 -0
- package/dist/src/formats/dot/styles.d.ts +82 -0
- package/dist/src/formats/dot/styles.d.ts.map +1 -0
- package/dist/src/formats/dot/styles.js +1496 -0
- package/dist/src/formats/dot/styles.js.map +1 -0
- package/dist/src/formats/gexf/exporter.d.ts.map +1 -1
- package/dist/src/formats/gexf/exporter.js +20 -5
- package/dist/src/formats/gexf/exporter.js.map +1 -1
- package/dist/src/formats/gexf/importer.d.ts +8 -1
- package/dist/src/formats/gexf/importer.d.ts.map +1 -1
- package/dist/src/formats/gexf/importer.js +251 -131
- package/dist/src/formats/gexf/importer.js.map +1 -1
- package/dist/src/formats/gexf/index.d.ts +8 -0
- package/dist/src/formats/gexf/index.d.ts.map +1 -1
- package/dist/src/formats/gexf/index.js +10 -2
- package/dist/src/formats/gexf/index.js.map +1 -1
- package/dist/src/formats/gexf/schema.d.ts +5 -0
- package/dist/src/formats/gexf/schema.d.ts.map +1 -1
- package/dist/src/formats/gexf/schema.js +5 -0
- package/dist/src/formats/gexf/schema.js.map +1 -1
- package/dist/src/formats/gexf/styles.d.ts +74 -0
- package/dist/src/formats/gexf/styles.d.ts.map +1 -0
- package/dist/src/formats/gexf/styles.js +604 -0
- package/dist/src/formats/gexf/styles.js.map +1 -0
- package/dist/src/formats/gml/exporter.d.ts +1 -5
- package/dist/src/formats/gml/exporter.d.ts.map +1 -1
- package/dist/src/formats/gml/exporter.js +19 -8
- package/dist/src/formats/gml/exporter.js.map +1 -1
- package/dist/src/formats/gml/importer.d.ts.map +1 -1
- package/dist/src/formats/gml/importer.js +4 -0
- package/dist/src/formats/gml/importer.js.map +1 -1
- package/dist/src/formats/gml/index.d.ts +2 -1
- package/dist/src/formats/gml/index.d.ts.map +1 -1
- package/dist/src/formats/gml/index.js +2 -1
- package/dist/src/formats/gml/index.js.map +1 -1
- package/dist/src/formats/gml/positions.d.ts +14 -0
- package/dist/src/formats/gml/positions.d.ts.map +1 -0
- package/dist/src/formats/gml/positions.js +46 -0
- package/dist/src/formats/gml/positions.js.map +1 -0
- package/dist/src/formats/gml/styles.d.ts +59 -0
- package/dist/src/formats/gml/styles.d.ts.map +1 -0
- package/dist/src/formats/gml/styles.js +1056 -0
- package/dist/src/formats/gml/styles.js.map +1 -0
- package/dist/src/formats/gml/syntax.d.ts +11 -0
- package/dist/src/formats/gml/syntax.d.ts.map +1 -1
- package/dist/src/formats/gml/syntax.js +151 -62
- package/dist/src/formats/gml/syntax.js.map +1 -1
- package/dist/src/formats/graphml/constants.d.ts +4 -0
- package/dist/src/formats/graphml/constants.d.ts.map +1 -1
- package/dist/src/formats/graphml/constants.js +5 -1
- package/dist/src/formats/graphml/constants.js.map +1 -1
- package/dist/src/formats/graphml/exporter.d.ts.map +1 -1
- package/dist/src/formats/graphml/exporter.js +133 -65
- package/dist/src/formats/graphml/exporter.js.map +1 -1
- package/dist/src/formats/graphml/importer.d.ts +4 -1
- package/dist/src/formats/graphml/importer.d.ts.map +1 -1
- package/dist/src/formats/graphml/importer.js +100 -44
- package/dist/src/formats/graphml/importer.js.map +1 -1
- package/dist/src/formats/graphml/index.d.ts +1 -0
- package/dist/src/formats/graphml/index.d.ts.map +1 -1
- package/dist/src/formats/graphml/index.js +1 -0
- package/dist/src/formats/graphml/index.js.map +1 -1
- package/dist/src/formats/graphml/styles-plain.d.ts +19 -0
- package/dist/src/formats/graphml/styles-plain.d.ts.map +1 -0
- package/dist/src/formats/graphml/styles-plain.js +187 -0
- package/dist/src/formats/graphml/styles-plain.js.map +1 -0
- package/dist/src/formats/graphml/styles-yed.d.ts +179 -0
- package/dist/src/formats/graphml/styles-yed.d.ts.map +1 -0
- package/dist/src/formats/graphml/styles-yed.js +1086 -0
- package/dist/src/formats/graphml/styles-yed.js.map +1 -0
- package/dist/src/formats/graphml/styles-yfiles3.d.ts +19 -0
- package/dist/src/formats/graphml/styles-yfiles3.d.ts.map +1 -0
- package/dist/src/formats/graphml/styles-yfiles3.js +508 -0
- package/dist/src/formats/graphml/styles-yfiles3.js.map +1 -0
- package/dist/src/formats/graphml/tree.d.ts.map +1 -1
- package/dist/src/formats/graphml/tree.js +34 -19
- package/dist/src/formats/graphml/tree.js.map +1 -1
- package/dist/src/formats/graphml/yfiles.d.ts +16 -2
- package/dist/src/formats/graphml/yfiles.d.ts.map +1 -1
- package/dist/src/formats/graphml/yfiles.js +83 -12
- package/dist/src/formats/graphml/yfiles.js.map +1 -1
- package/dist/src/formats/json/exporter.d.ts +5 -0
- package/dist/src/formats/json/exporter.d.ts.map +1 -1
- package/dist/src/formats/json/exporter.js +68 -25
- package/dist/src/formats/json/exporter.js.map +1 -1
- package/dist/src/formats/json/importer.d.ts +22 -3
- package/dist/src/formats/json/importer.d.ts.map +1 -1
- package/dist/src/formats/json/importer.js +439 -264
- package/dist/src/formats/json/importer.js.map +1 -1
- package/dist/src/formats/json/positions.d.ts +16 -0
- package/dist/src/formats/json/positions.d.ts.map +1 -0
- package/dist/src/formats/json/positions.js +44 -0
- package/dist/src/formats/json/positions.js.map +1 -0
- package/dist/src/formats/json/styles.d.ts +102 -0
- package/dist/src/formats/json/styles.d.ts.map +1 -0
- package/dist/src/formats/json/styles.js +1753 -0
- package/dist/src/formats/json/styles.js.map +1 -0
- package/dist/src/formats/neo4j/exporter.d.ts.map +1 -1
- package/dist/src/formats/neo4j/exporter.js +2 -1
- package/dist/src/formats/neo4j/exporter.js.map +1 -1
- package/dist/src/formats/pajek/exporter.d.ts +2 -0
- package/dist/src/formats/pajek/exporter.d.ts.map +1 -1
- package/dist/src/formats/pajek/exporter.js +142 -76
- package/dist/src/formats/pajek/exporter.js.map +1 -1
- package/dist/src/formats/pajek/importer.d.ts +4 -0
- package/dist/src/formats/pajek/importer.d.ts.map +1 -1
- package/dist/src/formats/pajek/importer.js +60 -6
- package/dist/src/formats/pajek/importer.js.map +1 -1
- package/dist/src/formats/pajek/index.d.ts +2 -0
- package/dist/src/formats/pajek/index.d.ts.map +1 -1
- package/dist/src/formats/pajek/index.js +2 -0
- package/dist/src/formats/pajek/index.js.map +1 -1
- package/dist/src/formats/pajek/styles.d.ts +50 -0
- package/dist/src/formats/pajek/styles.d.ts.map +1 -0
- package/dist/src/formats/pajek/styles.js +569 -0
- package/dist/src/formats/pajek/styles.js.map +1 -0
- package/dist/src/formats/pajek/syntax.d.ts +6 -0
- package/dist/src/formats/pajek/syntax.d.ts.map +1 -1
- package/dist/src/formats/pajek/syntax.js +6 -0
- package/dist/src/formats/pajek/syntax.js.map +1 -1
- package/dist/src/formats/xgmml/columns.d.ts.map +1 -1
- package/dist/src/formats/xgmml/columns.js +34 -9
- package/dist/src/formats/xgmml/columns.js.map +1 -1
- package/dist/src/formats/xgmml/constants.d.ts +2 -0
- package/dist/src/formats/xgmml/constants.d.ts.map +1 -1
- package/dist/src/formats/xgmml/constants.js +3 -1
- package/dist/src/formats/xgmml/constants.js.map +1 -1
- package/dist/src/formats/xgmml/document.d.ts +12 -8
- package/dist/src/formats/xgmml/document.d.ts.map +1 -1
- package/dist/src/formats/xgmml/document.js +56 -13
- package/dist/src/formats/xgmml/document.js.map +1 -1
- package/dist/src/formats/xgmml/emit.d.ts.map +1 -1
- package/dist/src/formats/xgmml/emit.js +12 -6
- package/dist/src/formats/xgmml/emit.js.map +1 -1
- package/dist/src/formats/xgmml/exporter.d.ts +3 -1
- package/dist/src/formats/xgmml/exporter.d.ts.map +1 -1
- package/dist/src/formats/xgmml/exporter.js +22 -9
- package/dist/src/formats/xgmml/exporter.js.map +1 -1
- package/dist/src/formats/xgmml/importer.d.ts +2 -1
- package/dist/src/formats/xgmml/importer.d.ts.map +1 -1
- package/dist/src/formats/xgmml/importer.js +31 -24
- package/dist/src/formats/xgmml/importer.js.map +1 -1
- package/dist/src/formats/xgmml/styles.d.ts +104 -0
- package/dist/src/formats/xgmml/styles.d.ts.map +1 -0
- package/dist/src/formats/xgmml/styles.js +310 -0
- package/dist/src/formats/xgmml/styles.js.map +1 -0
- package/dist/src/index.d.ts +9 -7
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +7 -7
- package/dist/src/index.js.map +1 -1
- package/dist/src/positions/codes.d.ts +31 -0
- package/dist/src/positions/codes.d.ts.map +1 -0
- package/dist/src/positions/codes.js +26 -0
- package/dist/src/positions/codes.js.map +1 -0
- package/dist/src/positions/convert.d.ts +58 -0
- package/dist/src/positions/convert.d.ts.map +1 -0
- package/dist/src/positions/convert.js +107 -0
- package/dist/src/positions/convert.js.map +1 -0
- package/dist/src/positions/extract.d.ts +27 -0
- package/dist/src/positions/extract.d.ts.map +1 -0
- package/dist/src/positions/extract.js +526 -0
- package/dist/src/positions/extract.js.map +1 -0
- package/dist/src/positions/index.d.ts +10 -0
- package/dist/src/positions/index.d.ts.map +1 -0
- package/dist/src/positions/index.js +9 -0
- package/dist/src/positions/index.js.map +1 -0
- package/dist/src/positions/types.d.ts +208 -0
- package/dist/src/positions/types.d.ts.map +1 -0
- package/dist/src/positions/types.js +10 -0
- package/dist/src/positions/types.js.map +1 -0
- package/dist/src/registry.d.ts +30 -0
- package/dist/src/registry.d.ts.map +1 -1
- package/dist/src/registry.js +130 -9
- package/dist/src/registry.js.map +1 -1
- package/dist/src/styles/annotations.d.ts +132 -0
- package/dist/src/styles/annotations.d.ts.map +1 -0
- package/dist/src/styles/annotations.js +320 -0
- package/dist/src/styles/annotations.js.map +1 -0
- package/dist/src/styles/budget.d.ts +45 -0
- package/dist/src/styles/budget.d.ts.map +1 -0
- package/dist/src/styles/budget.js +58 -0
- package/dist/src/styles/budget.js.map +1 -0
- package/dist/src/styles/canon/bends.d.ts +32 -0
- package/dist/src/styles/canon/bends.d.ts.map +1 -0
- package/dist/src/styles/canon/bends.js +74 -0
- package/dist/src/styles/canon/bends.js.map +1 -0
- package/dist/src/styles/canon/color-tables.d.ts +22 -0
- package/dist/src/styles/canon/color-tables.d.ts.map +1 -0
- package/dist/src/styles/canon/color-tables.js +369 -0
- package/dist/src/styles/canon/color-tables.js.map +1 -0
- package/dist/src/styles/canon/color.d.ts +66 -0
- package/dist/src/styles/canon/color.d.ts.map +1 -0
- package/dist/src/styles/canon/color.js +548 -0
- package/dist/src/styles/canon/color.js.map +1 -0
- package/dist/src/styles/canon/enums.d.ts +25 -0
- package/dist/src/styles/canon/enums.d.ts.map +1 -0
- package/dist/src/styles/canon/enums.js +187 -0
- package/dist/src/styles/canon/enums.js.map +1 -0
- package/dist/src/styles/canon/graphviz.d.ts +48 -0
- package/dist/src/styles/canon/graphviz.d.ts.map +1 -0
- package/dist/src/styles/canon/graphviz.js +160 -0
- package/dist/src/styles/canon/graphviz.js.map +1 -0
- package/dist/src/styles/canon/index.d.ts +13 -0
- package/dist/src/styles/canon/index.d.ts.map +1 -0
- package/dist/src/styles/canon/index.js +13 -0
- package/dist/src/styles/canon/index.js.map +1 -0
- package/dist/src/styles/canon/number.d.ts +59 -0
- package/dist/src/styles/canon/number.d.ts.map +1 -0
- package/dist/src/styles/canon/number.js +142 -0
- package/dist/src/styles/canon/number.js.map +1 -0
- package/dist/src/styles/canon/site.d.ts +51 -0
- package/dist/src/styles/canon/site.d.ts.map +1 -0
- package/dist/src/styles/canon/site.js +63 -0
- package/dist/src/styles/canon/site.js.map +1 -0
- package/dist/src/styles/canon/text.d.ts +61 -0
- package/dist/src/styles/canon/text.d.ts.map +1 -0
- package/dist/src/styles/canon/text.js +199 -0
- package/dist/src/styles/canon/text.js.map +1 -0
- package/dist/src/styles/codes.d.ts +95 -0
- package/dist/src/styles/codes.d.ts.map +1 -0
- package/dist/src/styles/codes.js +97 -0
- package/dist/src/styles/codes.js.map +1 -0
- package/dist/src/styles/cyjs/cascade.d.ts +134 -0
- package/dist/src/styles/cyjs/cascade.d.ts.map +1 -0
- package/dist/src/styles/cyjs/cascade.js +2252 -0
- package/dist/src/styles/cyjs/cascade.js.map +1 -0
- package/dist/src/styles/cyjs/defaults-table.d.ts +25 -0
- package/dist/src/styles/cyjs/defaults-table.d.ts.map +1 -0
- package/dist/src/styles/cyjs/defaults-table.js +76 -0
- package/dist/src/styles/cyjs/defaults-table.js.map +1 -0
- package/dist/src/styles/cyjs/emit.d.ts +82 -0
- package/dist/src/styles/cyjs/emit.d.ts.map +1 -0
- package/dist/src/styles/cyjs/emit.js +791 -0
- package/dist/src/styles/cyjs/emit.js.map +1 -0
- package/dist/src/styles/cyjs/index.d.ts +13 -0
- package/dist/src/styles/cyjs/index.d.ts.map +1 -0
- package/dist/src/styles/cyjs/index.js +13 -0
- package/dist/src/styles/cyjs/index.js.map +1 -0
- package/dist/src/styles/cyjs/live.d.ts +46 -0
- package/dist/src/styles/cyjs/live.d.ts.map +1 -0
- package/dist/src/styles/cyjs/live.js +108 -0
- package/dist/src/styles/cyjs/live.js.map +1 -0
- package/dist/src/styles/cyjs/mappers.d.ts +147 -0
- package/dist/src/styles/cyjs/mappers.d.ts.map +1 -0
- package/dist/src/styles/cyjs/mappers.js +744 -0
- package/dist/src/styles/cyjs/mappers.js.map +1 -0
- package/dist/src/styles/cyjs/selector.d.ts +113 -0
- package/dist/src/styles/cyjs/selector.d.ts.map +1 -0
- package/dist/src/styles/cyjs/selector.js +611 -0
- package/dist/src/styles/cyjs/selector.js.map +1 -0
- package/dist/src/styles/cyjs/stylesheet-text.d.ts +37 -0
- package/dist/src/styles/cyjs/stylesheet-text.d.ts.map +1 -0
- package/dist/src/styles/cyjs/stylesheet-text.js +181 -0
- package/dist/src/styles/cyjs/stylesheet-text.js.map +1 -0
- package/dist/src/styles/cytoscape/emit.d.ts +125 -0
- package/dist/src/styles/cytoscape/emit.d.ts.map +1 -0
- package/dist/src/styles/cytoscape/emit.js +1025 -0
- package/dist/src/styles/cytoscape/emit.js.map +1 -0
- package/dist/src/styles/cytoscape/index.d.ts +10 -0
- package/dist/src/styles/cytoscape/index.d.ts.map +1 -0
- package/dist/src/styles/cytoscape/index.js +10 -0
- package/dist/src/styles/cytoscape/index.js.map +1 -0
- package/dist/src/styles/cytoscape/lexicon.d.ts +49 -0
- package/dist/src/styles/cytoscape/lexicon.d.ts.map +1 -0
- package/dist/src/styles/cytoscape/lexicon.js +605 -0
- package/dist/src/styles/cytoscape/lexicon.js.map +1 -0
- package/dist/src/styles/cytoscape/mappings.d.ts +171 -0
- package/dist/src/styles/cytoscape/mappings.d.ts.map +1 -0
- package/dist/src/styles/cytoscape/mappings.js +460 -0
- package/dist/src/styles/cytoscape/mappings.js.map +1 -0
- package/dist/src/styles/cytoscape/resolve.d.ts +137 -0
- package/dist/src/styles/cytoscape/resolve.d.ts.map +1 -0
- package/dist/src/styles/cytoscape/resolve.js +381 -0
- package/dist/src/styles/cytoscape/resolve.js.map +1 -0
- package/dist/src/styles/cytoscape/translate.d.ts +50 -0
- package/dist/src/styles/cytoscape/translate.d.ts.map +1 -0
- package/dist/src/styles/cytoscape/translate.js +156 -0
- package/dist/src/styles/cytoscape/translate.js.map +1 -0
- package/dist/src/styles/defaults.d.ts +90 -0
- package/dist/src/styles/defaults.d.ts.map +1 -0
- package/dist/src/styles/defaults.js +414 -0
- package/dist/src/styles/defaults.js.map +1 -0
- package/dist/src/styles/index.d.ts +15 -0
- package/dist/src/styles/index.d.ts.map +1 -0
- package/dist/src/styles/index.js +14 -0
- package/dist/src/styles/index.js.map +1 -0
- package/dist/src/styles/internal.d.ts +17 -0
- package/dist/src/styles/internal.d.ts.map +1 -0
- package/dist/src/styles/internal.js +16 -0
- package/dist/src/styles/internal.js.map +1 -0
- package/dist/src/styles/io/approximations.d.ts +24 -0
- package/dist/src/styles/io/approximations.d.ts.map +1 -0
- package/dist/src/styles/io/approximations.js +51 -0
- package/dist/src/styles/io/approximations.js.map +1 -0
- package/dist/src/styles/io/block.d.ts +166 -0
- package/dist/src/styles/io/block.d.ts.map +1 -0
- package/dist/src/styles/io/block.js +930 -0
- package/dist/src/styles/io/block.js.map +1 -0
- package/dist/src/styles/io/generic.d.ts +88 -0
- package/dist/src/styles/io/generic.d.ts.map +1 -0
- package/dist/src/styles/io/generic.js +516 -0
- package/dist/src/styles/io/generic.js.map +1 -0
- package/dist/src/styles/io/index.d.ts +8 -0
- package/dist/src/styles/io/index.d.ts.map +1 -0
- package/dist/src/styles/io/index.js +7 -0
- package/dist/src/styles/io/index.js.map +1 -0
- package/dist/src/styles/io/writer.d.ts +89 -0
- package/dist/src/styles/io/writer.d.ts.map +1 -0
- package/dist/src/styles/io/writer.js +626 -0
- package/dist/src/styles/io/writer.js.map +1 -0
- package/dist/src/styles/notes.d.ts +47 -0
- package/dist/src/styles/notes.d.ts.map +1 -0
- package/dist/src/styles/notes.js +140 -0
- package/dist/src/styles/notes.js.map +1 -0
- package/dist/src/styles/plan/classes.d.ts +31 -0
- package/dist/src/styles/plan/classes.d.ts.map +1 -0
- package/dist/src/styles/plan/classes.js +139 -0
- package/dist/src/styles/plan/classes.js.map +1 -0
- package/dist/src/styles/plan/continuous.d.ts +32 -0
- package/dist/src/styles/plan/continuous.d.ts.map +1 -0
- package/dist/src/styles/plan/continuous.js +165 -0
- package/dist/src/styles/plan/continuous.js.map +1 -0
- package/dist/src/styles/plan/discrete.d.ts +39 -0
- package/dist/src/styles/plan/discrete.d.ts.map +1 -0
- package/dist/src/styles/plan/discrete.js +127 -0
- package/dist/src/styles/plan/discrete.js.map +1 -0
- package/dist/src/styles/plan/families.d.ts +31 -0
- package/dist/src/styles/plan/families.d.ts.map +1 -0
- package/dist/src/styles/plan/families.js +95 -0
- package/dist/src/styles/plan/families.js.map +1 -0
- package/dist/src/styles/plan/features.d.ts +58 -0
- package/dist/src/styles/plan/features.d.ts.map +1 -0
- package/dist/src/styles/plan/features.js +185 -0
- package/dist/src/styles/plan/features.js.map +1 -0
- package/dist/src/styles/plan/index.d.ts +7 -0
- package/dist/src/styles/plan/index.d.ts.map +1 -0
- package/dist/src/styles/plan/index.js +7 -0
- package/dist/src/styles/plan/index.js.map +1 -0
- package/dist/src/styles/plan/plan.d.ts +71 -0
- package/dist/src/styles/plan/plan.d.ts.map +1 -0
- package/dist/src/styles/plan/plan.js +893 -0
- package/dist/src/styles/plan/plan.js.map +1 -0
- package/dist/src/styles/plan/resolve.d.ts +137 -0
- package/dist/src/styles/plan/resolve.d.ts.map +1 -0
- package/dist/src/styles/plan/resolve.js +587 -0
- package/dist/src/styles/plan/resolve.js.map +1 -0
- package/dist/src/styles/types.d.ts +702 -0
- package/dist/src/styles/types.d.ts.map +1 -0
- package/dist/src/styles/types.js +10 -0
- package/dist/src/styles/types.js.map +1 -0
- package/dist/src/styles/vocabulary.d.ts +41 -0
- package/dist/src/styles/vocabulary.d.ts.map +1 -0
- package/dist/src/styles/vocabulary.js +140 -0
- package/dist/src/styles/vocabulary.js.map +1 -0
- package/dist/src/types.d.ts +64 -1
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js.map +1 -1
- package/dist/styles.d.ts +1 -0
- package/dist/styles.js +322 -0
- package/dist/styles.js.map +1 -0
- package/dist/xgmml.js +5 -4
- package/dist/xgmml.js.map +1 -1
- package/package.json +13 -2
- package/src/common/codes.ts +7 -0
- package/src/common/escape.ts +5 -2
- package/src/common/export.ts +179 -140
- package/src/common/input.ts +8 -4
- package/src/common/json-elements.ts +169 -38
- package/src/common/notes.ts +94 -0
- package/src/common/report.ts +41 -1
- package/src/common/units.ts +42 -0
- package/src/common/xml.ts +45 -5
- package/src/formats/cx/exporter.ts +95 -11
- package/src/formats/cx/importer.ts +126 -90
- package/src/formats/cx/styles.ts +304 -0
- package/src/formats/cx2/exporter.ts +234 -77
- package/src/formats/cx2/importer.ts +19 -1
- package/src/formats/cx2/styles.ts +29 -0
- package/src/formats/cys/constants.ts +3 -0
- package/src/formats/cys/exporter.ts +246 -60
- package/src/formats/cys/importer.ts +125 -9
- package/src/formats/cys/session.ts +6 -0
- package/src/formats/cys/styles.ts +254 -0
- package/src/formats/cys/tables.ts +117 -48
- package/src/formats/dot/exporter.ts +262 -126
- package/src/formats/dot/importer.ts +111 -20
- package/src/formats/dot/index.ts +1 -0
- package/src/formats/dot/positions.ts +77 -0
- package/src/formats/dot/styles.ts +1755 -0
- package/src/formats/gexf/exporter.ts +27 -11
- package/src/formats/gexf/importer.ts +308 -158
- package/src/formats/gexf/index.ts +10 -0
- package/src/formats/gexf/schema.ts +5 -0
- package/src/formats/gexf/styles.ts +719 -0
- package/src/formats/gml/exporter.ts +33 -14
- package/src/formats/gml/importer.ts +4 -0
- package/src/formats/gml/index.ts +2 -1
- package/src/formats/gml/positions.ts +52 -0
- package/src/formats/gml/styles.ts +1248 -0
- package/src/formats/gml/syntax.ts +173 -62
- package/src/formats/graphml/constants.ts +5 -0
- package/src/formats/graphml/exporter.ts +163 -71
- package/src/formats/graphml/importer.ts +119 -45
- package/src/formats/graphml/index.ts +1 -0
- package/src/formats/graphml/styles-plain.ts +236 -0
- package/src/formats/graphml/styles-yed.ts +1221 -0
- package/src/formats/graphml/styles-yfiles3.ts +573 -0
- package/src/formats/graphml/tree.ts +36 -20
- package/src/formats/graphml/yfiles.ts +89 -13
- package/src/formats/json/exporter.ts +76 -26
- package/src/formats/json/importer.ts +541 -322
- package/src/formats/json/positions.ts +50 -0
- package/src/formats/json/styles.ts +2082 -0
- package/src/formats/neo4j/exporter.ts +2 -1
- package/src/formats/pajek/exporter.ts +195 -106
- package/src/formats/pajek/importer.ts +78 -9
- package/src/formats/pajek/index.ts +2 -0
- package/src/formats/pajek/styles.ts +685 -0
- package/src/formats/pajek/syntax.ts +7 -0
- package/src/formats/xgmml/columns.ts +39 -9
- package/src/formats/xgmml/constants.ts +3 -0
- package/src/formats/xgmml/document.ts +54 -12
- package/src/formats/xgmml/emit.ts +11 -6
- package/src/formats/xgmml/exporter.ts +32 -13
- package/src/formats/xgmml/importer.ts +43 -29
- package/src/formats/xgmml/styles.ts +400 -0
- package/src/index.ts +16 -0
- package/src/positions/codes.ts +32 -0
- package/src/positions/convert.ts +123 -0
- package/src/positions/extract.ts +619 -0
- package/src/positions/index.ts +23 -0
- package/src/positions/types.ts +221 -0
- package/src/registry.ts +179 -8
- package/src/styles/annotations.ts +478 -0
- package/src/styles/budget.ts +60 -0
- package/src/styles/canon/bends.ts +84 -0
- package/src/styles/canon/color-tables.ts +386 -0
- package/src/styles/canon/color.ts +624 -0
- package/src/styles/canon/enums.ts +211 -0
- package/src/styles/canon/graphviz.ts +189 -0
- package/src/styles/canon/index.ts +13 -0
- package/src/styles/canon/number.ts +152 -0
- package/src/styles/canon/site.ts +87 -0
- package/src/styles/canon/text.ts +221 -0
- package/src/styles/codes.ts +104 -0
- package/src/styles/cyjs/cascade.ts +2670 -0
- package/src/styles/cyjs/defaults-table.ts +82 -0
- package/src/styles/cyjs/emit.ts +952 -0
- package/src/styles/cyjs/index.ts +37 -0
- package/src/styles/cyjs/live.ts +147 -0
- package/src/styles/cyjs/mappers.ts +879 -0
- package/src/styles/cyjs/selector.ts +778 -0
- package/src/styles/cyjs/stylesheet-text.ts +214 -0
- package/src/styles/cytoscape/emit.ts +1264 -0
- package/src/styles/cytoscape/index.ts +40 -0
- package/src/styles/cytoscape/lexicon.ts +658 -0
- package/src/styles/cytoscape/mappings.ts +603 -0
- package/src/styles/cytoscape/resolve.ts +521 -0
- package/src/styles/cytoscape/translate.ts +237 -0
- package/src/styles/defaults.ts +504 -0
- package/src/styles/index.ts +57 -0
- package/src/styles/internal.ts +17 -0
- package/src/styles/io/approximations.ts +47 -0
- package/src/styles/io/block.ts +1138 -0
- package/src/styles/io/generic.ts +687 -0
- package/src/styles/io/index.ts +18 -0
- package/src/styles/io/writer.ts +780 -0
- package/src/styles/notes.ts +165 -0
- package/src/styles/plan/classes.ts +166 -0
- package/src/styles/plan/continuous.ts +218 -0
- package/src/styles/plan/discrete.ts +165 -0
- package/src/styles/plan/families.ts +115 -0
- package/src/styles/plan/features.ts +234 -0
- package/src/styles/plan/index.ts +7 -0
- package/src/styles/plan/plan.ts +1129 -0
- package/src/styles/plan/resolve.ts +685 -0
- package/src/styles/types.ts +814 -0
- package/src/styles/vocabulary.ts +172 -0
- package/src/types.ts +76 -1
- package/dist/chunks/constants-fT3E8JYY.js.map +0 -1
- package/dist/chunks/escape-B62ZGM_a.js.map +0 -1
- package/dist/chunks/export-rKLeGQMo.js.map +0 -1
- package/dist/chunks/exporter-8hLNemFk.js.map +0 -1
- package/dist/chunks/exporter-BWwEuOPT.js.map +0 -1
- package/dist/chunks/exporter-RVtXVetw.js.map +0 -1
- package/dist/chunks/importer-BbNb7eNg.js.map +0 -1
- package/dist/chunks/importer-C98dpSH4.js.map +0 -1
- package/dist/chunks/importer-D794XUTe.js.map +0 -1
- package/dist/chunks/importer-Dz7tI8Sa.js.map +0 -1
- package/dist/chunks/importer-Ht7LNg8L.js.map +0 -1
- package/dist/chunks/importer-WrGRZb0N.js.map +0 -1
- package/dist/chunks/importer-xZ-3suY1.js.map +0 -1
- package/dist/chunks/json-elements-DKSqpNW1.js.map +0 -1
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A discrete mapping on one categorical feature: the feature's values fall inside the family's blocks, up to 20% of
|
|
3
|
+
* the styled elements excepted, and the elements missing the feature may form their own group.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { type Family, valueKey } from "./families.js";
|
|
7
|
+
import type { FeatureInfo } from "./features.js";
|
|
8
|
+
|
|
9
|
+
/** Below this many styled elements anything explains anything: no mapping is tried. */
|
|
10
|
+
export const MIN_MAPPED = 8;
|
|
11
|
+
/** The most keys a discrete table may hold. */
|
|
12
|
+
const MAX_KEYS = 256;
|
|
13
|
+
/** The share of styled elements a mapping may get wrong; the replay moves them into the exceptions. */
|
|
14
|
+
const MAX_EXCEPTION_SHARE = 0.2;
|
|
15
|
+
|
|
16
|
+
/** A key of a discrete table, as the feature holds it. */
|
|
17
|
+
type KeyValue = string | number | boolean;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* A discrete mapping that explains a family.
|
|
21
|
+
*/
|
|
22
|
+
export interface DiscreteCandidate {
|
|
23
|
+
/** The kind of candidate. */
|
|
24
|
+
readonly type: "discrete";
|
|
25
|
+
/** The feature the table reads. */
|
|
26
|
+
readonly info: FeatureInfo;
|
|
27
|
+
/** Each key (by its value key) with its raw value and the block it maps to. */
|
|
28
|
+
readonly table: Map<string, { readonly raw: KeyValue; readonly block: number }>;
|
|
29
|
+
/** The block the elements missing the feature share, or null. */
|
|
30
|
+
readonly bucket: number | null;
|
|
31
|
+
/** The description cost. */
|
|
32
|
+
readonly cost: number;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Tests a discrete mapping on one feature.
|
|
37
|
+
* @param fam - the family
|
|
38
|
+
* @param info - the feature
|
|
39
|
+
* @param n - the element count
|
|
40
|
+
* @param spend - spends work from the budget
|
|
41
|
+
* @returns the candidate, or null when the feature does not explain the family
|
|
42
|
+
*/
|
|
43
|
+
export function discreteCandidate(
|
|
44
|
+
fam: Family,
|
|
45
|
+
info: FeatureInfo,
|
|
46
|
+
n: number,
|
|
47
|
+
spend: (ops: number) => void,
|
|
48
|
+
): DiscreteCandidate | null {
|
|
49
|
+
const nF = fam.styled.length;
|
|
50
|
+
if (!info.categorical || info.raw || nF < MIN_MAPPED) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
if (info.distinct < 2 || info.distinct > Math.min(MAX_KEYS, nF / 2) || info.distinct >= 0.9 * n) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
spend(n);
|
|
57
|
+
const { values } = info.feature;
|
|
58
|
+
const { votes, nullBlocks } = votesOf(fam, values);
|
|
59
|
+
const { table, exceptions: wrong } = tableOf(votes);
|
|
60
|
+
let exceptions = wrong;
|
|
61
|
+
// never paint an element the file left unstyled
|
|
62
|
+
const unstyledMissing = unstyledOf(fam, values, table, n);
|
|
63
|
+
if (unstyledMissing === null) {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
// the elements missing the key form one group when they share one style (Gephi's "null" partition)
|
|
67
|
+
let bucket: number | null = null;
|
|
68
|
+
if (nullBlocks.size === 1 && !unstyledMissing) {
|
|
69
|
+
bucket = nullBlocks.keys().next().value ?? null;
|
|
70
|
+
} else {
|
|
71
|
+
for (const c of nullBlocks.values()) {
|
|
72
|
+
exceptions += c;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (exceptions > Math.max(2, MAX_EXCEPTION_SHARE * nF)) {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
const cost =
|
|
79
|
+
50 + table.size * fam.props.length + (exceptions > 0 ? 50 + exceptions : 0) + (bucket === null ? 0 : 50);
|
|
80
|
+
return { type: "discrete", info, table, bucket, cost };
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** How the styled elements of each key fall into the family's blocks. */
|
|
84
|
+
type Votes = Map<string, { raw: KeyValue; counts: Map<number, number> }>;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Counts, per key of the feature, the styled elements in each block; and per block, those missing the feature.
|
|
88
|
+
* @param fam - the family
|
|
89
|
+
* @param values - the feature's values
|
|
90
|
+
* @returns the votes, and the blocks of the elements missing the feature
|
|
91
|
+
*/
|
|
92
|
+
function votesOf(fam: Family, values: readonly (KeyValue | null)[]): { votes: Votes; nullBlocks: Map<number, number> } {
|
|
93
|
+
const votes: Votes = new Map();
|
|
94
|
+
const nullBlocks = new Map<number, number>();
|
|
95
|
+
for (const i of fam.styled) {
|
|
96
|
+
const b = fam.blocks[i];
|
|
97
|
+
const kv = values[i];
|
|
98
|
+
if (kv === null) {
|
|
99
|
+
nullBlocks.set(b, (nullBlocks.get(b) ?? 0) + 1);
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
const key = valueKey(kv);
|
|
103
|
+
let vote = votes.get(key);
|
|
104
|
+
if (vote === undefined) {
|
|
105
|
+
vote = { raw: kv, counts: new Map() };
|
|
106
|
+
votes.set(key, vote);
|
|
107
|
+
}
|
|
108
|
+
vote.counts.set(b, (vote.counts.get(b) ?? 0) + 1);
|
|
109
|
+
}
|
|
110
|
+
return { votes, nullBlocks };
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* The table: each key maps to the block most of its elements are in; the others are exceptions.
|
|
115
|
+
* @param votes - the votes
|
|
116
|
+
* @returns the table and how many elements it gets wrong
|
|
117
|
+
*/
|
|
118
|
+
function tableOf(votes: Votes): { table: Map<string, { raw: KeyValue; block: number }>; exceptions: number } {
|
|
119
|
+
const table = new Map<string, { raw: KeyValue; block: number }>();
|
|
120
|
+
let exceptions = 0;
|
|
121
|
+
for (const [key, { raw, counts }] of votes) {
|
|
122
|
+
let best = -1;
|
|
123
|
+
let bestCount = -1;
|
|
124
|
+
let total = 0;
|
|
125
|
+
for (const [b, c] of counts) {
|
|
126
|
+
total += c;
|
|
127
|
+
if (c > bestCount) {
|
|
128
|
+
bestCount = c;
|
|
129
|
+
best = b;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
table.set(key, { raw, block: best });
|
|
133
|
+
exceptions += total - bestCount;
|
|
134
|
+
}
|
|
135
|
+
return { table, exceptions };
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Whether an element the file left unstyled misses the feature (or holds false, which a missing-key group's "not has"
|
|
140
|
+
* also matches).
|
|
141
|
+
* @param fam - the family
|
|
142
|
+
* @param values - the feature's values
|
|
143
|
+
* @param table - the table
|
|
144
|
+
* @param n - the element count
|
|
145
|
+
* @returns the answer, or null when the table would paint an unstyled element
|
|
146
|
+
*/
|
|
147
|
+
function unstyledOf(
|
|
148
|
+
fam: Family,
|
|
149
|
+
values: readonly (KeyValue | null)[],
|
|
150
|
+
table: ReadonlyMap<string, unknown>,
|
|
151
|
+
n: number,
|
|
152
|
+
): boolean | null {
|
|
153
|
+
let missing = false;
|
|
154
|
+
for (let i = 0; i < n; i++) {
|
|
155
|
+
const v = values[i];
|
|
156
|
+
if (fam.blocks[i] !== 0) {
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
if (v !== null && table.has(valueKey(v))) {
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
missing ||= v === null || v === false;
|
|
163
|
+
}
|
|
164
|
+
return missing;
|
|
165
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Exact equivalence classes: every property's values partition the elements (null is a block of its own), and
|
|
3
|
+
* properties with identical partitions form one family, explained once.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { StyleValue } from "../types.js";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A group of properties that partition the elements the same way.
|
|
10
|
+
*/
|
|
11
|
+
export interface Family {
|
|
12
|
+
/** The properties, in the order they were given. */
|
|
13
|
+
readonly props: string[];
|
|
14
|
+
/** Each element's block: 0 for null, 1.. by first appearance. */
|
|
15
|
+
readonly blocks: Int32Array;
|
|
16
|
+
/** The number of non-null blocks. */
|
|
17
|
+
readonly k: number;
|
|
18
|
+
/** The elements with a value (block above 0), ascending. */
|
|
19
|
+
readonly styled: number[];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The text a value is compared by.
|
|
24
|
+
* @param v - the value
|
|
25
|
+
* @returns a key unique per value and type
|
|
26
|
+
*/
|
|
27
|
+
export function valueKey(v: string | number | boolean | null | undefined): string {
|
|
28
|
+
return v === null || v === undefined ? "\u0000null" : `${typeof v}:${String(v)}`;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The partition of the elements by a property's values.
|
|
33
|
+
* @param values - the values by element
|
|
34
|
+
* @returns each element's block (0 for null, then by first appearance) and the number of non-null blocks
|
|
35
|
+
*/
|
|
36
|
+
function partition(values: readonly (StyleValue | null)[]): { blocks: Int32Array; k: number } {
|
|
37
|
+
const ids = new Map<string, number>();
|
|
38
|
+
const blocks = new Int32Array(values.length);
|
|
39
|
+
for (let i = 0; i < values.length; i++) {
|
|
40
|
+
const v = values[i];
|
|
41
|
+
if (v === null) {
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
const key = valueKey(v);
|
|
45
|
+
let id = ids.get(key);
|
|
46
|
+
if (id === undefined) {
|
|
47
|
+
id = ids.size + 1;
|
|
48
|
+
ids.set(key, id);
|
|
49
|
+
}
|
|
50
|
+
blocks[i] = id;
|
|
51
|
+
}
|
|
52
|
+
return { blocks, k: ids.size };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* A hash of a block array.
|
|
57
|
+
* @param blocks - the blocks
|
|
58
|
+
* @returns its hash
|
|
59
|
+
*/
|
|
60
|
+
function hashBlocks(blocks: Int32Array): number {
|
|
61
|
+
let h = 0x811c9dc5;
|
|
62
|
+
for (const b of blocks) {
|
|
63
|
+
h = Math.imul(h ^ b, 0x01000193);
|
|
64
|
+
}
|
|
65
|
+
return h >>> 0;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Whether two block arrays are equal.
|
|
70
|
+
* @param a - one
|
|
71
|
+
* @param b - the other
|
|
72
|
+
* @returns true when equal
|
|
73
|
+
*/
|
|
74
|
+
function sameBlocks(a: Int32Array, b: Int32Array): boolean {
|
|
75
|
+
if (a.length !== b.length) {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
for (let i = 0; i < a.length; i++) {
|
|
79
|
+
if (a[i] !== b[i]) {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Groups properties by identical partitions.
|
|
88
|
+
* @param props - the properties, each with its values
|
|
89
|
+
* @returns the families, in the order of their first property
|
|
90
|
+
*/
|
|
91
|
+
export function familiesOf(props: readonly (readonly [string, readonly (StyleValue | null)[]])[]): Family[] {
|
|
92
|
+
const byHash = new Map<number, Family[]>();
|
|
93
|
+
const out: Family[] = [];
|
|
94
|
+
for (const [p, values] of props) {
|
|
95
|
+
const { blocks, k } = partition(values);
|
|
96
|
+
const h = hashBlocks(blocks);
|
|
97
|
+
const list = byHash.get(h) ?? [];
|
|
98
|
+
const hit = list.find((f) => sameBlocks(f.blocks, blocks));
|
|
99
|
+
if (hit !== undefined) {
|
|
100
|
+
hit.props.push(p);
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
const styled: number[] = [];
|
|
104
|
+
for (let i = 0; i < blocks.length; i++) {
|
|
105
|
+
if (blocks[i] !== 0) {
|
|
106
|
+
styled.push(i);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
const fam: Family = { props: [p], blocks, k, styled };
|
|
110
|
+
list.push(fam);
|
|
111
|
+
byHash.set(h, list);
|
|
112
|
+
out.push(fam);
|
|
113
|
+
}
|
|
114
|
+
return out;
|
|
115
|
+
}
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Candidate explaining columns: the snapshot's attributes and the graph's degrees, which the planner tests as
|
|
3
|
+
* explanations of a file's per-element style values, and the fingerprint that ties styles to their graph.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { GraphSnapshot } from "@graphty/graph-format";
|
|
7
|
+
|
|
8
|
+
import type { ColumnRef, Scalar, StyleFeature, StyleFingerprint, StyleTarget } from "../types.js";
|
|
9
|
+
import { dataCell, degreeValues } from "./resolve.js";
|
|
10
|
+
|
|
11
|
+
/** Column types whose values can be features: one scalar per element. */
|
|
12
|
+
const SCALAR_DTYPES: ReadonlySet<string> = new Set(["string", "dict", "bool", "i32", "u32", "u8", "f32", "f64"]);
|
|
13
|
+
/** Coordinates say where the writer put a node, not what it is. */
|
|
14
|
+
const COORDINATE = /^(?:x|y|z|_pos)$/i;
|
|
15
|
+
/** The column holding the group a node sits in. */
|
|
16
|
+
const PARENT_COLUMN = "graphty.parent";
|
|
17
|
+
/** An integer column of at least this many values that fills a whole range is an index, not a quantity. */
|
|
18
|
+
const MIN_INDEX = 8;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The candidate explaining columns of one target: every scalar attribute (the reserved `graphty.*` columns,
|
|
22
|
+
* coordinates and Cytoscape's selection state excepted), the group a node sits in as the style column `group`, and
|
|
23
|
+
* for nodes the degree (and the in- and out-degree of a directed graph) as `{ computed }` references, which follow
|
|
24
|
+
* later edits of the graph.
|
|
25
|
+
* @param snapshot - the graph
|
|
26
|
+
* @param target - nodes or edges
|
|
27
|
+
* @returns the features, in column order with the degrees last
|
|
28
|
+
* @category Styles
|
|
29
|
+
*/
|
|
30
|
+
export function featuresOf(snapshot: GraphSnapshot, target: StyleTarget): StyleFeature[] {
|
|
31
|
+
const table = target === "node" ? snapshot.nodes : snapshot.edges;
|
|
32
|
+
const n = target === "node" ? snapshot.nodeCount : snapshot.edgeCount;
|
|
33
|
+
const out: StyleFeature[] = [];
|
|
34
|
+
for (const name of table.names().filter((c) => isFeatureColumn(table, c))) {
|
|
35
|
+
const values = Array.from({ length: n }, (_, i): Scalar | null => {
|
|
36
|
+
const v = dataCell(table, name, i);
|
|
37
|
+
return typeof v === "string" || typeof v === "number" || typeof v === "boolean" ? v : null;
|
|
38
|
+
});
|
|
39
|
+
if (name !== PARENT_COLUMN) {
|
|
40
|
+
out.push({ ref: { data: name }, values });
|
|
41
|
+
} else if (target === "node") {
|
|
42
|
+
// the group a node sits in, by the group's id: graphty-element keeps no graphty.* column in its records
|
|
43
|
+
const group = values.map((v) =>
|
|
44
|
+
typeof v === "number" && v >= 0 && v < snapshot.nodeCount ? String(snapshot.ids.idOf(v)) : null,
|
|
45
|
+
);
|
|
46
|
+
out.push({ ref: { style: "group" }, values: group });
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (target === "node" && n > 0) {
|
|
50
|
+
const kinds: ("degree" | "indegree" | "outdegree")[] = snapshot.directed
|
|
51
|
+
? ["degree", "indegree", "outdegree"]
|
|
52
|
+
: ["degree"];
|
|
53
|
+
for (const k of kinds) {
|
|
54
|
+
out.push({ ref: { computed: k }, values: degreeValues(snapshot, k) });
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return out;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Whether a column may explain styles: one scalar component, neither a position nor a coordinate, nor graphty's own
|
|
62
|
+
* columns (the parent excepted) or Cytoscape's selection state.
|
|
63
|
+
* @param table - the node or edge table
|
|
64
|
+
* @param name - the column
|
|
65
|
+
* @returns true for a candidate
|
|
66
|
+
*/
|
|
67
|
+
function isFeatureColumn(table: GraphSnapshot["nodes"], name: string): boolean {
|
|
68
|
+
if ((name.startsWith("graphty.") && name !== PARENT_COLUMN) || name === "selected" || COORDINATE.test(name)) {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
const col = table.get(name);
|
|
72
|
+
return (
|
|
73
|
+
col !== null && col.meta.role !== "position" && SCALAR_DTYPES.has(col.meta.dtype) && col.meta.components === 1
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* The fingerprint of a graph: its node and edge counts and a hash of its node ids' text, whatever their order (a
|
|
79
|
+
* format may read nodes back in another order). The id 7 and the id "7" hash alike, so a graph written to a format
|
|
80
|
+
* that reads its ids back as text (or as numbers) keeps its fingerprint.
|
|
81
|
+
* @param snapshot - the graph
|
|
82
|
+
* @returns the fingerprint
|
|
83
|
+
* @category Styles
|
|
84
|
+
*/
|
|
85
|
+
export function styleFingerprint(snapshot: GraphSnapshot): StyleFingerprint {
|
|
86
|
+
// two FNV-1a hashes with different seeds over each id's text, summed: the sum does not depend on the order
|
|
87
|
+
let h1 = 0;
|
|
88
|
+
let h2 = 0;
|
|
89
|
+
for (let i = 0; i < snapshot.nodeCount; i++) {
|
|
90
|
+
const text = String(snapshot.ids.idOf(i));
|
|
91
|
+
let a = 0x811c9dc5;
|
|
92
|
+
let b = 0x01000193 ^ 0x5bd1e995;
|
|
93
|
+
for (let c = 0; c < text.length; c++) {
|
|
94
|
+
const code = text.charCodeAt(c); // NOSONAR(S7758): hashes UTF-16 code units; code points would change every fingerprint
|
|
95
|
+
a = Math.imul(a ^ code, 0x01000193);
|
|
96
|
+
b = Math.imul(b ^ code, 0x01000193) ^ (b >>> 13);
|
|
97
|
+
}
|
|
98
|
+
h1 = (h1 + (a >>> 0)) >>> 0;
|
|
99
|
+
h2 = (h2 + (b >>> 0)) >>> 0;
|
|
100
|
+
}
|
|
101
|
+
const hex = (h: number): string => (h >>> 0).toString(16).padStart(8, "0");
|
|
102
|
+
return {
|
|
103
|
+
nodes: snapshot.nodeCount,
|
|
104
|
+
edges: snapshot.edgeCount,
|
|
105
|
+
heldEdges: heldEdgeRows(snapshot).length,
|
|
106
|
+
ids: hex(h1) + hex(h2),
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* The edge rows a file holds, in order: every row but the second half of an undirected edge in a directed graph,
|
|
112
|
+
* which every format writes once.
|
|
113
|
+
* @param snapshot - the graph
|
|
114
|
+
* @returns the rows
|
|
115
|
+
*/
|
|
116
|
+
export function heldEdgeRows(snapshot: GraphSnapshot): number[] {
|
|
117
|
+
const pair = snapshot.edges.byRole("pair");
|
|
118
|
+
const rows: number[] = [];
|
|
119
|
+
for (let e = 0; e < snapshot.edgeCount; e++) {
|
|
120
|
+
if (!(pair?.isSet(e) === true && (pair.value(e) as number) < e)) {
|
|
121
|
+
rows.push(e);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return rows;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** What describeFeature() reads off a feature's values. */
|
|
128
|
+
interface ValueStats {
|
|
129
|
+
/** The distinct values, as type and text. */
|
|
130
|
+
readonly seen: ReadonlySet<string>;
|
|
131
|
+
/** Whether every value is text, a boolean or a finite integer. */
|
|
132
|
+
readonly categorical: boolean;
|
|
133
|
+
/** Whether every value is a finite number. */
|
|
134
|
+
readonly numeric: boolean;
|
|
135
|
+
/** Whether every value is an integer. */
|
|
136
|
+
readonly integers: boolean;
|
|
137
|
+
/** The smallest finite number. */
|
|
138
|
+
readonly lo: number;
|
|
139
|
+
/** The largest finite number. */
|
|
140
|
+
readonly hi: number;
|
|
141
|
+
/** How many values are set. */
|
|
142
|
+
readonly count: number;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* The statistics of a feature's values.
|
|
147
|
+
* @param values - the values
|
|
148
|
+
* @returns the statistics
|
|
149
|
+
*/
|
|
150
|
+
function valueStats(values: readonly (Scalar | null)[]): ValueStats {
|
|
151
|
+
const seen = new Set<string>();
|
|
152
|
+
let categorical = true;
|
|
153
|
+
let numeric = true;
|
|
154
|
+
let integers = true;
|
|
155
|
+
let lo = Infinity;
|
|
156
|
+
let hi = -Infinity;
|
|
157
|
+
let count = 0;
|
|
158
|
+
for (const v of values) {
|
|
159
|
+
if (v === null) {
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
count++;
|
|
163
|
+
seen.add(`${typeof v}:${String(v)}`);
|
|
164
|
+
if (typeof v !== "number") {
|
|
165
|
+
numeric = false;
|
|
166
|
+
integers = false;
|
|
167
|
+
} else if (Number.isFinite(v)) {
|
|
168
|
+
integers &&= Number.isInteger(v);
|
|
169
|
+
categorical &&= Number.isInteger(v);
|
|
170
|
+
lo = Math.min(lo, v);
|
|
171
|
+
hi = Math.max(hi, v);
|
|
172
|
+
} else {
|
|
173
|
+
numeric = false;
|
|
174
|
+
categorical = false;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return { seen, categorical, numeric, integers, lo, hi, count };
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* A feature's name in rule ids: the column's name, the generated key or the degree's name.
|
|
182
|
+
* @param ref - the column
|
|
183
|
+
* @returns its name
|
|
184
|
+
*/
|
|
185
|
+
function featureName(ref: ColumnRef): string {
|
|
186
|
+
if ("style" in ref) {
|
|
187
|
+
return ref.style;
|
|
188
|
+
}
|
|
189
|
+
if ("computed" in ref) {
|
|
190
|
+
return ref.computed;
|
|
191
|
+
}
|
|
192
|
+
return (ref as { data: string }).data;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* What the planner knows about a feature.
|
|
197
|
+
*/
|
|
198
|
+
export interface FeatureInfo {
|
|
199
|
+
/** The feature. */
|
|
200
|
+
readonly feature: StyleFeature;
|
|
201
|
+
/** Its name in rule ids. */
|
|
202
|
+
readonly name: string;
|
|
203
|
+
/** Distinct non-null values. */
|
|
204
|
+
readonly distinct: number;
|
|
205
|
+
/** Whether a table on it may explain styles (strings, booleans, integers). */
|
|
206
|
+
readonly categorical: boolean;
|
|
207
|
+
/** Whether a ramp on it may explain styles (finite numbers that are not an index). */
|
|
208
|
+
readonly numeric: boolean;
|
|
209
|
+
/** Whether it is the file's own raw style column, which explains nothing. */
|
|
210
|
+
readonly raw: boolean;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Describes a feature for the planner.
|
|
215
|
+
* @param feature - the feature
|
|
216
|
+
* @param raw - whether it is the raw style column a reader read
|
|
217
|
+
* @returns what the planner knows about it
|
|
218
|
+
*/
|
|
219
|
+
export function describeFeature(feature: StyleFeature, raw: boolean): FeatureInfo {
|
|
220
|
+
const { seen, categorical, numeric, integers, lo, hi, count } = valueStats(feature.values);
|
|
221
|
+
const computed = "computed" in feature.ref;
|
|
222
|
+
// an integer column whose values are all different and fill a whole range (0..n-1, a z order) is an index:
|
|
223
|
+
// a ramp on it would only replay the order the writer stored the elements in
|
|
224
|
+
const index =
|
|
225
|
+
!computed && numeric && integers && count >= MIN_INDEX && seen.size === count && hi - lo + 1 === count;
|
|
226
|
+
return {
|
|
227
|
+
feature,
|
|
228
|
+
name: featureName(feature.ref),
|
|
229
|
+
distinct: seen.size,
|
|
230
|
+
categorical: count > 0 && categorical,
|
|
231
|
+
numeric: count > 0 && numeric && !index,
|
|
232
|
+
raw,
|
|
233
|
+
};
|
|
234
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The planner, the candidate features and the reference resolver of a file's styles.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export { featuresOf, styleFingerprint } from "./features.js";
|
|
6
|
+
export { MAX_STYLE_RULES, type PlanOptions, planStyles, type StyleValues } from "./plan.js";
|
|
7
|
+
export { resolveStyles } from "./resolve.js";
|