updateGraph(graph) {
    this._graph = graph;
    // nodes
    const newNodeMap = {};
    const newColaNodes = graph.getNodes().map(node => {
      const oldColaNode = this._nodeMap[node.getId()];
      const newColaNode = oldColaNode
        ? oldColaNode
        : {
            id: node.getId(),
            x: 0,
            y: 0,
          };

      newNodeMap[node.getId()] = newColaNode;
      return newColaNode;
    });
    this._nodeMap = newNodeMap;
    this._colaGraph.nodes = newColaNodes;
    // edges
    const newEdgeMap = {};
    const newColaEdges = graph.getEdges().map(edge => {
      const newColaEdge = {
        id: edge.getId(),
        source: this._colaGraph.nodes.findIndex(
          n => n.id === edge.getSourceNodeId()
        ),
        target: this._colaGraph.nodes.findIndex(
          n => n.id === edge.getTargetNodeId()
        ),
      };
      newEdgeMap[edge.getId()] = newColaEdge;
      return newColaEdge;
    });
    this._edgeMap = newEdgeMap;
    this._colaGraph.edges = newColaEdges;
  }
// 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) {
    this._graph = graph;
    const newNodeMap = {};
    const newColaNodes = graph.getNodes().map(node => {
      const oldColaNode = this._nodeMap[node.getId()];
      const newColaNode = oldColaNode
        ? oldColaNode
        : {
            id: node.getId(),
            x: 0,
            y: 0,
          };
      newNodeMap[node.getId()] = newColaNode;
      return newColaNode;
    });
    this._nodeMap = newNodeMap;
    this._colaGraph.nodes = newColaNodes;
    const newEdgeMap = {};
    const newColaEdges = graph.getEdges().map(edge => {
      const newColaEdge = {
        id: edge.getId(),
        source: this._colaGraph.nodes.findIndex(
          n => n.id === edge.getSourceNodeId()
        ),
        target: this._colaGraph.nodes.findIndex(
          n => n.id === edge.getTargetNodeId()
        ),
      };
      newEdgeMap[edge.getId()] = newColaEdge;
      return newColaEdge;
    });
    this._edgeMap = newEdgeMap;
    this._colaGraph.edges = newColaEdges;
  }
updateGraph ( graph ) { this . _graph = graph ; const newNodeMap = { } ; const newColaNodes = graph . getNodes ( ) . map ( node => { const oldColaNode = this . _nodeMap [ node . getId ( ) ] ; const newColaNode = oldColaNode ? oldColaNode : { id : node . getId ( ) , x : 0 , y : 0 , } ; newNodeMap [ node . getId ( ) ] = newColaNode ; return newColaNode ; } ) ; this . _nodeMap = newNodeMap ; this . _colaGraph . nodes = newColaNodes ; const newEdgeMap = { } ; const newColaEdges = graph . getEdges ( ) . map ( edge => { const newColaEdge = { id : edge . getId ( ) , source : this . _colaGraph . nodes . findIndex ( n => n . id === edge . getSourceNodeId ( ) ) , target : this . _colaGraph . nodes . findIndex ( n => n . id === edge . getTargetNodeId ( ) ) , } ; newEdgeMap [ edge . getId ( ) ] = newColaEdge ; return newColaEdge ; } ) ; this . _edgeMap = newEdgeMap ; this . _colaGraph . edges = newColaEdges ; }
for steaming new data on the same graph
for steaming new data on the same graph
// nodes // edges