import { Parent } from "unist" ; import { Graph } from "graphlib" ; import { toD3Force } from "./to-d3-force" ; param root returns export function toGraphlib ( root ) { const { nodes , links } = toD3Force ( root ) ; var digraph = new Graph ( ) ; for ( let node of nodes ) { const { NAME } = node . data || { } ; digraph . setNode ( node . data ?. xref_id as string , { label : NAME ? NAME . replace ( /^@/ , "" ) : node . type , } ) ; } for ( let link of links ) { digraph . setEdge ( link . source , link . target , { label : link . value } ) ; } return digraph ; }