How to use the @antv/g6.Util.getAdjMatrix function in @antv/g6

To help you get started, we’ve selected a few @antv/g6 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github antvis / G6 / plugins / radial / index.js View on Github external
focusNode = nodes[i];
          self.set('focusNode', focusNode);
          found = true;
          i = nodes.length;
        }
      }
      if (!found) focusNode = null;
    }
    // default focus node
    if (!focusNode) {
      focusNode = nodes[0];
      if (!focusNode) return;
      self.set('focusNode', focusNode);
    }
    // the graph-theoretic distance (shortest path distance) matrix
    const adjMatrix = Util.getAdjMatrix(data, false);
    const D = Util.floydWarshall(adjMatrix);
    self.set('distances', D);

    // the index of the focusNode in data
    const focusIndex = getIndexById(nodes, focusNode.id);
    self.set('focusIndex', focusIndex);
    // the shortest path distance from each node to focusNode
    const focusNodeD = D[focusIndex];
    const width = graph.get('width');
    const height = graph.get('height');
    // the maxRadius of the graph
    const maxRadius = height > width ? width / 2 : height / 2;
    const maxD = Math.max(...focusNodeD);
    // the radius for each nodes away from focusNode
    const radii = [];
    focusNodeD.forEach((value, i) => {
github antvis / G6 / plugins / mds / index.js View on Github external
focusNode = nodes[i];
          self.set('focusNode', focusNode);
          found = true;
          i = nodes.length;
        }
      }
      if (!found) focusNode = null;
    }
    // default focus node
    if (!focusNode) {
      focusNode = nodes[0];
      if (!focusNode) return;
      self.set('focusNode', focusNode);
    }
    // the graph-theoretic distance (shortest path distance) matrix
    const adjMatrix = Util.getAdjMatrix(data, false);
    const D = Util.floydWarshall(adjMatrix);
    self.set('distances', D);

    // scale the ideal edge length acoording to linkDistance
    const scaledD = Util.scaleMatrix(D, linkDistance);
    self.set('scaledDistances', scaledD);

    // get positions by MDS
    const positions = self.runMDS();
    self.set('positions', positions);
    positions.forEach((p, i) => {
      nodes[i].x = p[0] + center[0];
      nodes[i].y = p[1] + center[1];
    });

    graph.refreshPositions();