title: How to make a weighted graph in Cytoscape.js?
body: <p>Im new to cytoscape, I have read the docs but can't find something that helps. Is there a way to make something like this (a weighted graph) in Cytoscape.js?:</p>
  <p><a href="https://i.stack.imgur.com/Mu6VZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Mu6VZ.png" alt="enter image description here" /></a></p>
  <p>I just need to know how to display the weight of the edge.</p>
  <p>So far I have this:</p>
  <pre><code>elements: [
    // list of graph elements to start with
    {
      // node a
      data: { id: &quot;a&quot; },
    },
    {
      // node b
      data: { id: &quot;b&quot; },
    },
    {
      // edge ab
      data: { id: &quot;ab&quot;, weight: 3, source: &quot;a&quot;, target: &quot;b&quot; },
    },
  ],
  </code></pre>
  <p>But adding a weight to the edge doesn't display the weight in the graph:
  <a href="https://i.stack.imgur.com/NlcZR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NlcZR.png" alt="enter image description here" /></a></p>