updateGraph(graph) {
    if (this._graph.getGraphName() !== graph.getGraphName()) {
      // reset the maps
      this._nodeMap = {};
      this._edgeMap = {};
    }
    this._graph = graph;
    // update internal layout data
    // nodes
    const newNodeMap = {};
    const newD3Nodes = graph.getNodes().map(node => {
      const id = node.id;
      const locked = node.getPropertyValue('locked') || false;
      const x = node.getPropertyValue('x') || 0;
      const y = node.getPropertyValue('y') || 0;
      const fx = locked ? x : null;
      const fy = locked ? y : null;
      const collisionRadius = node.getPropertyValue('collisionRadius') || 0;

      const oldD3Node = this._nodeMap[node.id];
      const newD3Node = oldD3Node
        ? oldD3Node
        : {id, x, y, fx, fy, collisionRadius};
      newNodeMap[node.id] = newD3Node;
      return newD3Node;
    });
    this._nodeMap = newNodeMap;
    this._d3Graph.nodes = newD3Nodes;
    // edges
    const newEdgeMap = {};
    const newD3Edges = graph.getEdges().map(edge => {
      const oldD3Edge = this._edgeMap[edge.id];
      const newD3Edge = oldD3Edge
        ? oldD3Edge
        : {
            id: edge.id,
            source: newNodeMap[edge.getSourceNodeId()],
            target: newNodeMap[edge.getTargetNodeId()],
          };
      newEdgeMap[edge.id] = newD3Edge;
      return newD3Edge;
    });
    this._edgeMap = newEdgeMap;
    this._d3Graph.edges = newD3Edges;
  }
// for steaming new data on the same graph
for steaming new data on the same graph
for steaming new data on the same graph
updateGraph(graph) {
    if (this._graph.getGraphName() !== graph.getGraphName()) {
      this._nodeMap = {};
      this._edgeMap = {};
    }
    this._graph = graph;
    const newNodeMap = {};
    const newD3Nodes = graph.getNodes().map(node => {
      const id = node.id;
      const locked = node.getPropertyValue('locked') || false;
      const x = node.getPropertyValue('x') || 0;
      const y = node.getPropertyValue('y') || 0;
      const fx = locked ? x : null;
      const fy = locked ? y : null;
      const collisionRadius = node.getPropertyValue('collisionRadius') || 0;
      const oldD3Node = this._nodeMap[node.id];
      const newD3Node = oldD3Node
        ? oldD3Node
        : {id, x, y, fx, fy, collisionRadius};
      newNodeMap[node.id] = newD3Node;
      return newD3Node;
    });
    this._nodeMap = newNodeMap;
    this._d3Graph.nodes = newD3Nodes;
    const newEdgeMap = {};
    const newD3Edges = graph.getEdges().map(edge => {
      const oldD3Edge = this._edgeMap[edge.id];
      const newD3Edge = oldD3Edge
        ? oldD3Edge
        : {
            id: edge.id,
            source: newNodeMap[edge.getSourceNodeId()],
            target: newNodeMap[edge.getTargetNodeId()],
          };
      newEdgeMap[edge.id] = newD3Edge;
      return newD3Edge;
    });
    this._edgeMap = newEdgeMap;
    this._d3Graph.edges = newD3Edges;
  }
updateGraph ( graph ) { if ( this . _graph . getGraphName ( ) !== graph . getGraphName ( ) ) { this . _nodeMap = { } ; this . _edgeMap = { } ; } this . _graph = graph ; const newNodeMap = { } ; const newD3Nodes = graph . getNodes ( ) . map ( node => { const id = node . id ; const locked = node . getPropertyValue ( 'locked' ) || false ; const x = node . getPropertyValue ( 'x' ) || 0 ; const y = node . getPropertyValue ( 'y' ) || 0 ; const fx = locked ? x : null ; const fy = locked ? y : null ; const collisionRadius = node . getPropertyValue ( 'collisionRadius' ) || 0 ; const oldD3Node = this . _nodeMap [ node . id ] ; const newD3Node = oldD3Node ? oldD3Node : { id , x , y , fx , fy , collisionRadius } ; newNodeMap [ node . id ] = newD3Node ; return newD3Node ; } ) ; this . _nodeMap = newNodeMap ; this . _d3Graph . nodes = newD3Nodes ; const newEdgeMap = { } ; const newD3Edges = graph . getEdges ( ) . map ( edge => { const oldD3Edge = this . _edgeMap [ edge . id ] ; const newD3Edge = oldD3Edge ? oldD3Edge : { id : edge . id , source : newNodeMap [ edge . getSourceNodeId ( ) ] , target : newNodeMap [ edge . getTargetNodeId ( ) ] , } ; newEdgeMap [ edge . id ] = newD3Edge ; return newD3Edge ; } ) ; this . _edgeMap = newEdgeMap ; this . _d3Graph . edges = newD3Edges ; }
for steaming new data on the same graph
for steaming new data on the same graph
// reset the maps // update internal layout data // nodes // edges