Atlaslog
Atlaslog / Examples / deck.gl / Business scenarios / 100,000-Node Relationship Network
deck.gl · Business scenario

100,000-Node Relationship Network

100,000 nodes form 12 community clusters joined by 30,000 sampled edges; nodes, edges or only cross-community links can be shown.

Open standalone → Chinese notes All business examples
/demos/deckgl-nongis-network-graph.htmlLIVE
single HTML file · CDN dependencies onlyinterface labels are in Chinese

Business context

Relationship networks at the 100,000-node level are common in social graphs, transaction fraud detection and knowledge graphs. The users are risk analysts, graph engineers and operations staff looking for community structure, bridge nodes and anomalous edges. Data comes from graph database exports or offline edge tables; production graphs often reach millions of nodes and tens of millions of edges, so browser views are sampled down to 100,000 nodes and tens of thousands of edges before interaction is discussed.

Graph data has no intrinsic coordinates, so a force-directed layout or community detection pass assigns two- or three-dimensional positions and then separates nodes by community; only a sampled subset of edges is kept, with cross-community edges stored separately for toggling. Cesium has no concept of graph layout, and three.js would require hand-written instancing and picking for 100,000 nodes; deck.gl treats the layout result as point coordinates, and two layers produce nodes and edges.

The most common misreading is that position carries business meaning: distance only reflects the repulsion parameters of the layout. Radius is compressed by a power law, so degrees of 90 and 30 do not look proportional. Edge alpha compensates for overlap density, so a brighter region often means denser sampling rather than stronger relationships.

How it works

Node indices are assigned to communities by index mod 12; community centers lie on a circle of radius 160, coordinates come from summing three uniform random numbers as an approximate Gaussian with a spread of about ±57 and a z jitter of ±27, and degree is pow(rand,3)×90, whose long tail approximates the power-law distribution of real networks. Of the 30,000 edges, 85% are sampled within communities and 15% across them; both ends reference the node coordinate array directly so LineLayer copies no coordinates, and cross-community edges are stored separately and swapped in wholesale when toggled.

Intra-community edges use a cool tone at alpha 22 and cross-community edges orange at alpha 70, so 30,000 overlapping segments do not merge into a solid block; width is 0.7 px with widthMinPixels 0.4 to stay visible when zoomed out. Both layers set pickable: false, since picking buffers for 100,000 points and 30,000 lines would cost tens of megabytes of GPU memory and hover is not needed here. Radius maps through 1.5 + √degree×0.5 and is clamped to 1–7 px, so a node with degree 90 does not cover an entire community.

SettingEffect
getRadius: 1.5 + √degree×0.5Compresses the long tail so high-degree nodes do not cover whole regions
alpha 22 / 70Opacity difference between intra- and cross-community edges
pickable: falseDisables picking and saves the picking buffer for 100,000 points
85% / 15%Sampling ratio of intra- to cross-community edges

Note. At the 100,000 scale, disable picking before discussing interaction; the lower bound for edge alpha follows overlap density and usually starts around 20.

Source

demos/deckgl-nongis-network-graph.html
<!--
  示例:十万节点关系网络
  要点:10 万节点按 12 个社区聚簇,3 万条采样边低透明度叠加,拾取全部关闭
  依赖:deck.gl 9.0 · jsDelivr CDN
-->
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta name="robots" content="noindex,follow">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>十万节点关系网络</title>
<style>
  html,body{height:100%;margin:0;background:#0d1117}
  body{display:flex;flex-direction:column;overflow:hidden;
       font:13px/1.6 -apple-system,"Segoe UI","PingFang SC",sans-serif;color:#e6e8ec}
  .bar{position:relative;z-index:5;flex:0 0 auto;padding:8px 12px;background:#161b22;border-bottom:1px solid #252c36;
       display:flex;gap:14px;align-items:center;font-size:12px;color:#8b93a1;flex-wrap:wrap}
  .bar b{color:#58a6ff;font-weight:600}
  .bar label{display:flex;align-items:center;gap:5px;cursor:pointer}
  .bar input[type=checkbox]{accent-color:#4f9ef8}
  .bar input[type=range]{width:150px;accent-color:#4f9ef8}
  .bar button{font:inherit;font-size:12px;padding:3px 10px;border-radius:4px;cursor:pointer;
       border:1px solid #2f3947;background:#1d242e;color:#c9d3e0}
  .bar button:hover{background:#26303d}
  .bar button.on{background:#2c4a7a;border-color:#4f8ad6;color:#dfe9ff}
  .bar .sep{width:1px;height:18px;background:#2a313c;margin:0 4px}
  #cv{flex:1 1 auto;min-height:0;width:100%;display:block}
</style>
</head>
<body>
<div class="bar">
  <span>节点 <b>100,000</b> · 边 <b id="en">30,000</b></span><span class="sep"></span>
  <button data-l="nodes">节点</button>
  <button data-l="edges">边</button>
  <button data-l="all" class="on">全部</button>
  <label><input id="cross" type="checkbox">只看跨社区边</label>
</div>
<canvas id="cv"></canvas>
<script src="https://cdn.jsdelivr.net/npm/deck.gl@9.0.35/dist.min.js"></script>
<script>
(function () {
  'use strict';

  if (typeof deck === 'undefined') {
    document.body.innerHTML =
      '<div style="padding:24px;color:#ff8c74">deck.gl 加载失败,请检查能否访问 cdn.jsdelivr.net</div>';
    return;
  }

  function rng(seed) {
    var a = seed >>> 0;
    return function () {
      a = (a + 0x6D2B79F5) >>> 0;
      var t = Math.imul(a ^ (a >>> 15), 1 | a);
      t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;
      return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
    };
  }

  var PALETTE = [
    [64, 154, 255], [86, 214, 168], [246, 186, 78],
    [240, 104, 72], [176, 132, 255], [64, 206, 226]
  ];
  var N = 100000, C = 12, TAU = Math.PI * 2;
  var rand = rng(31337);
  var i, j;

  var colors = [];
  for (i = 0; i < C; i++) {
    var base = PALETTE[i % 6];
    var mul = i < 6 ? 1 : 0.72;
    colors.push([
      Math.round(base[0] * mul),
      Math.round(base[1] * mul),
      Math.round(base[2] * mul),
      222
    ]);
  }

  var nodes = new Array(N);
  for (i = 0; i < N; i++) {
    var c = i % C;
    var ang = c / C * TAU;
    var g1 = (rand() + rand() + rand() - 1.5) * 38;
    var g2 = (rand() + rand() + rand() - 1.5) * 38;
    nodes[i] = {
      p: [Math.cos(ang) * 160 + g1, Math.sin(ang) * 160 + g2, (rand() - 0.5) * 55],
      c: c,
      w: 1 + Math.floor(Math.pow(rand(), 3) * 90)
    };
  }

  var members = [];
  for (i = 0; i < C; i++) members.push([]);
  for (i = 0; i < N; i++) members[nodes[i].c].push(i);

  var edges = [], crossEdges = [];
  while (edges.length < 30000) {
    var c1 = (rand() * C) | 0;
    var l1 = members[c1];
    var i1 = l1[(rand() * l1.length) | 0];
    var isCross = rand() < 0.15;
    var i2;
    if (isCross) {
      var c2 = (c1 + 1 + ((rand() * (C - 1)) | 0)) % C;
      var l2 = members[c2];
      i2 = l2[(rand() * l2.length) | 0];
    } else {
      i2 = l1[(rand() * l1.length) | 0];
      if (i2 === i1) continue;
    }
    var e = { s: nodes[i1].p, t: nodes[i2].p, cross: isCross };
    edges.push(e);
    if (isCross) crossEdges.push(e);
  }

  var showNodes = true, showEdges = true, crossOnly = false;
  var enEl = document.getElementById('en');

  function buildLayers() {
    var layers = [];
    if (showEdges) {
      layers.push(new deck.LineLayer({
        id: 'net-edges',
        data: crossOnly ? crossEdges : edges,
        coordinateSystem: deck.COORDINATE_SYSTEM.CARTESIAN,
        getSourcePosition: function (d) { return d.s; },
        getTargetPosition: function (d) { return d.t; },
        getColor: function (d) {
          return d.cross ? [255, 172, 92, 70] : [118, 168, 255, 22];
        },
        getWidth: 0.7,
        widthUnits: 'pixels',
        widthMinPixels: 0.4,
        pickable: false
      }));
    }
    if (showNodes) {
      layers.push(new deck.ScatterplotLayer({
        id: 'net-nodes',
        data: nodes,
        coordinateSystem: deck.COORDINATE_SYSTEM.CARTESIAN,
        getPosition: function (d) { return d.p; },
        getFillColor: function (d) { return colors[d.c]; },
        getRadius: function (d) { return 1.5 + Math.sqrt(d.w) * 0.5; },
        radiusUnits: 'pixels',
        radiusMinPixels: 1,
        radiusMaxPixels: 7,
        opacity: 0.9,
        pickable: false
      }));
    }
    return layers;
  }

  var deckgl = new deck.Deck({
    canvas: 'cv',
    width: '100%',
    height: '100%',
    views: new deck.OrbitView({ target: [0, 0, 0], fovy: 20 }),
    initialViewState: { target: [0, 0, 0], rotationX: 28, rotationOrbit: -32, zoom: 0.3 },
    controller: true,
    layers: buildLayers()
  });

  var btns = document.querySelectorAll('.bar button[data-l]');
  for (i = 0; i < btns.length; i++) {
    btns[i].addEventListener('click', function () {
      var mode = this.getAttribute('data-l');
      showNodes = mode !== 'edges';
      showEdges = mode !== 'nodes';
      for (j = 0; j < btns.length; j++) {
        btns[j].className = btns[j] === this ? 'on' : '';
      }
      deckgl.setProps({ layers: buildLayers() });
    });
  }

  document.getElementById('cross').addEventListener('change', function () {
    crossOnly = this.checked;
    enEl.textContent = (crossOnly ? crossEdges.length : edges.length).toLocaleString();
    deckgl.setProps({ layers: buildLayers() });
  });

  window.__deck = deckgl;
})();
</script>
</body>
</html>
Language: this page is in English; the demo keeps Chinese interface labels and code comments. The Chinese page carries the full notes and the same runnable file.

More business examples

deck.gl · APIScatterplotLayer deck.gl · APILineLayer deck.gl · APIOrbitView