Small world
      
        Generate a graph from the Erdős–Rényi (ER) model. It can be called with either (n,p) or (n,m) options. We apply a layout after the graph is generated.
      
      
      
        
      
      
        Open in a new window.
      
      
        
          <!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <script src="../build/ogma.min.js"></script>
  <style>
    #graph-container { top: 0; bottom: 0; left: 0; right: 0; position: absolute; margin: 0; overflow: hidden; }
    #load {
      position: absolute;
      top: 0;
      left: 0;
      padding: 5px;
      color: #fff;
      background: #141229;
      font-size: 12px;
      font-family: monospace;
    }
  </style>
</head>
<body>
  <div id="graph-container"></div>
  <span id="load">Loading...</span>
<script>
'use strict';
var ogma = new Ogma({
  container: 'graph-container'
});
ogma.generate.erdosRenyi({
  nodes : 100,
  p: 0.1
}).then(function(graph) {
  return ogma.setGraph(graph);
}).then(function() {
  // Apply a layout then adjust the view to show the whole graph and remove the 'Loading...' banner.
  return ogma.layouts.forceLink()
}).then(function() {
  return ogma.view.locateGraph({
    easing: 'linear',
    duration: 300
  });
}).then(function() {
  // Remove the 'Loading...' banner.
  document.getElementById('load').parentElement.removeChild(document.getElementById('load'));
})
</script>
</body>
</html>