const {
  Node,
  Link,
  Graph
} = require("./graph");

console.log(Graph);

class Tree extends Graph {
  constructor(NodeType) {
    super(NodeType);
  }

  addLink(link) {
    if (this.nodes[link.to.id].in.length > 0) {
      throw new Error("Cannot have 2 parents... Its a tree dude!");
    }

    super.addLink(link);
  }

}

let tree = new Tree(Node);
var A = new Node("A");
var B = new Node('B');
var C = new Node('C');
var D = new Node('D');
var E = new Node('E');
var F = new Node("F");
var AB = new Link(A, B);
var AC = new Link(A, C);
var CD = new Link(C, D);
var DE = new Link(D, E);
tree.addNode(A);
tree.addNode(B);
tree.addNode(C);
tree.addNode(D);
tree.addNode(E);
tree.addNode(F);
tree.addLink(AB);
tree.addLink(AC);
tree.addLink(CD);
tree.addLink(DE);