import { select, json, zoom, drag, event } from 'd3';
// import { createContextMenu } from './contextMenu.js';
//----------------------------------------
//------------------------------------------
// Adjaceny List Class
//-------------------------------------------
class Graph {
constructor() {
this.t = new Map();
}
addEdge(node1, node2) {
const s = this.t.get(node1);
if (s == null) this.t.set(node1, new Set([node2]));
else s.add(node2);
}
getAdjacencies(node) {
var z = this.t.get(node);
if (z == null) {
z = new Set();
}
return z;
}
*dir(node, path = Array(), visited = new Set()) {
yield [...path, node];
path.push(node);
visited.add(node);
for (const adj of this.getAdjacencies(node)) {
if (!visited.has(adj)) {
yield* this.dir(adj, path, visited);
}
}
path.pop();
}
*dirs(nodes) {
for (const node of nodes) {