import * as d3 from 'd3';
import { Link } from './link';

export class Node implements d3.SimulationNodeDatum {
  /**
   * Node’s zero-based index into nodes array. This property is set during the initialization process of a simulation.
   */
  index?: number;
  /**
   * Node’s current x-position
   */
  x?: number;
  /**
   * Node’s current y-position
   */
  y?: number;
  /**
   * Node’s current x-velocity
   */
  vx?: number;
  /**
   * Node’s current y-velocity
   */
  vy?: number;
  /**
   * Node’s fixed x-position (if position was fixed)
   */
  fx?: number | null;
  /**
   * Node’s fixed y-position (if position was fixed)
   */
  fy?: number | null;

  r?: number;

  id: string;

  group?: string;

  target?: any;

  image?: string;

  links?: Link[];

  constructor(id) {
    this.id = id;
    this.links = [];
  }

  addLink(link: Link) {
    this.links.push(link);
  }

}
