title: How do I represent a graph given as an adjacency list in C#?
body: <p>I am going to program various graph algorithms, and as input, I have given graphs on the form of adjacency lists.</p>
  
  <p>Here's an example:</p>
  
  <p>1 2 3 4</p>
  
  <p>2 1 3 4</p>
  
  <p>3 1 2 4</p>
  
  <p>4 1 2 3 5</p>
  
  <p>5 4 6</p>
  
  <p>6 5</p>
  
  <p>The graph has 6 vertices, represented by 6 rows (and the first entry of each row denotes the number of the vertex representing that row). The remaining entries in a row denote the vertices that the vertex corresponding to that row are adjacent to.</p>
  
  <p>What is a good way of representing this in C#? The differing number of entries in each row seem to rule out an array, so I found these <a href="http://www.dotnetperls.com/nested-list" rel="nofollow">lists of lists</a>.</p>
  
  <p>I am going to manipulate the graph, e.g. <a href="https://en.wikipedia.org/wiki/Edge_contraction" rel="nofollow">contract edges</a>, and I am looking for a data structure in which graph manipulations are both possible and efficient.</p>