import clone_default from "../../../lodash-es/clone.js";
import map_default from "../../../lodash-es/map.js";
import isUndefined_default from "../../../lodash-es/isUndefined.js";
import "./graph.js";
function write(n) {
	var r = {
		options: {
			directed: n.isDirected(),
			multigraph: n.isMultigraph(),
			compound: n.isCompound()
		},
		nodes: writeNodes(n),
		edges: writeEdges(n)
	};
	return isUndefined_default(n.graph()) || (r.value = clone_default(n.graph())), r;
}
function writeNodes(e) {
	return map_default(e.nodes(), function(n) {
		var r = e.node(n), i = e.parent(n), a = { v: n };
		return isUndefined_default(r) || (a.value = r), isUndefined_default(i) || (a.parent = i), a;
	});
}
function writeEdges(e) {
	return map_default(e.edges(), function(n) {
		var r = e.edge(n), i = {
			v: n.v,
			w: n.w
		};
		return isUndefined_default(n.name) || (i.name = n.name), isUndefined_default(r) || (i.value = r), i;
	});
}
export { write };
