function formatTooltip(d) {
let tooltip = d.data.name;
const both = intersection(d.incoming, d.outgoing);
const incoming = subtract(d.incoming, both, (p) => p[0]);
const outgoing = subtract(d.outgoing, both, (p) => p[1]);
const getName = (d) => d.data.name;
const displayLink = (prefix, d) => `${prefix} ${getName(d)}`;
const displayLinks = (prefix, ds, getItem) =>
ds.map((d) => displayLink(prefix, getItem(d))).join("\n");
tooltip += "\n" + displayLinks("←", incoming, (p) => p[0]);
tooltip += "\n" + displayLinks("↔", both, (p) => p[0]);
tooltip += "\n" + displayLinks("→", outgoing, (p) => p[1]);
return tooltip;
}