How to use the gojs.Set function in gojs

To help you get started, we’ve selected a few gojs 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 nimble-platform / frontend-service / src / app / explorative-search / layout / RadialLayout.ts View on Github external
let bestvert: any = null;
      let it = coll.iterator;
      while (it.next()) {
        let v = it.value;
        let dist = v.distance;
        if (dist < bestdist) {
          bestdist = dist;
          bestvert = v;
        }
      }
      return bestvert;
    }

    // keep track of vertexes we have finished examining;
    // this avoids unnecessary traversals and helps keep the SEEN collection small
    let finished = new go.Set(RadialVertex);
    while (seen.count > 0) {
      // look at the unfinished vertex with the shortest distance so far
      let least = leastVertex(seen);
      let leastdist = least.distance;
      // by the end of this loop we will have finished examining this LEAST vertex
      seen.remove(least);
      finished.add(least);
      // look at all edges connected with this vertex
      least.edges.each(function(e: any) {
        let neighbor = e.getOtherVertex(least);
        // skip vertexes that we have finished
        if (finished.contains(neighbor)) {return; }
        let neighbordist = neighbor.distance;
        // assume "distance" along a link is unitary, but could be any non-negative number.
        let dist = leastdist + 1;
        if (dist < neighbordist) {
github nimble-platform / frontend-service / src / app / explorative-search / layout / RadialLayout.ts View on Github external
private findDistances(source: RadialVertex) {
    let diagram = this.diagram;
    // keep track of distances from the source node
    this.network.vertexes.each(function(v: RadialVertex) { v.distance = Infinity; });
    // the source node starts with distance 0
    source.distance = 0;
    // keep track of nodes for we have set a non-Infinity distance,
    // but which we have not yet finished examining
    let seen = new go.Set(RadialVertex);
    seen.add(source);

    // local function for finding a vertex with the smallest distance in a given collection
    function leastVertex(coll: any) {
      let bestdist = Infinity;
      let bestvert: any = null;
      let it = coll.iterator;
      while (it.next()) {
        let v = it.value;
        let dist = v.distance;
        if (dist < bestdist) {
          bestdist = dist;
          bestvert = v;
        }
      }
      return bestvert;

gojs

Interactive diagrams, charts, and graphs, such as trees, flowcharts, orgcharts, UML, BPMN, or business diagrams

SEE LICENSE IN license.html
Latest version published 2 days ago

Package Health Score

77 / 100
Full package analysis