title: Computing array of relationships from tags
body: <p>I'm working on a <a href="https://github.com/d3/d3-force" rel="nofollow noreferrer">d3-force visualisation</a>, which requires
  data in a specific shape. I've got an array of objects, each with an array of tags.</p>
  <pre class="lang-js prettyprint-override"><code>nodes = [
    { name: &quot;post1&quot;, tag_list: [&quot;activity&quot;, &quot;online&quot;] },
    { name: &quot;post2&quot;, tag_list: [&quot;workshop&quot;, &quot;online&quot;] },
    { name: &quot;post3&quot;, tag_list: [&quot;english&quot;, &quot;workshop&quot;] },
    ...
  ]
  </code></pre>
  <p>To establish connections between data, I need to explicitly define an array of links:</p>
  <pre class="lang-js prettyprint-override"><code>links = [
    { 
      source: 'post1', 
      target: 'post2' 
    },
    { 
      source: 'post2', 
      target: 'post3' 
    },
    ...
  ]
  </code></pre>
  <p>There is no difference in similarity between links - all relationships are linear and carry the same <em>&quot;agency&quot;</em>. Identical data should ideally be filtered to prevent duplicate lines.</p>
  <p>How can I generate a link array of the previously mentioned shape from the <code>tag_list</code> arrays?</p>
  <p><a href="https://observablehq.com/@d3/force-directed-graph?collection=@d3/d3-force#miserables" rel="nofollow noreferrer">Here's an example of the required data structure.</a></p>
  <p>--</p>
  <p>Some context: I'm trying to visualise thematic overlaps between blog pages. All pages have an array of tags to describe them (<code>tag_list</code>). I wish to connect all tags within the graph. Since <code>d3</code> requires verbose references to draw links (see link below), I need to compute these from the tag lists that are accessible to me.</p>