title: Algorithm to generate interval graph
body: <p>I wonder if there is any algorithm or some easy procedure to generate an <a href="http://en.wikipedia.org/wiki/Interval_graph" rel="nofollow">interval graph</a>?<br>
  I need to generate interval graphs with <code>n</code> nodes, where <code>n</code> is changing for 1 to, say, 10000.<br>
  If it is possible, I need an incidence matrix representation of the graph.<br>
  An additional restriction is not to have all these graphs complete. </p>
  
  <p>Thanks everyone in advance!</p>
  
  <p><strong>==ADDITION==</strong>  </p>
  
  <p>Here is an implementation in Java:</p>
  
  <pre><code>public Object generate(int numberOfNodes) {
      int listCapacity = numberOfNodes * 2;
      List&lt;Integer&gt; arr = new ArrayList&lt;Integer&gt;();
      int[][] adjacencyMatrix = new int[numberOfNodes][numberOfNodes];
      Integer nodeNumber = 0;
      for (int i = 0; i &lt; listCapacity; i = i + 2) {
          arr.add(nodeNumber);
          arr.add(nodeNumber);
          nodeNumber++;
      }
  
      Collections.shuffle(arr);
  
      for (int i = 0; i &lt; numberOfNodes; i++) {
          for (int j = arr.indexOf(i); j &lt; arr.lastIndexOf(i); j++) {
              adjacencyMatrix[i][arr.get(j)] = 1;
              adjacencyMatrix[arr.get(j)][i] = 1;
          }
          adjacencyMatrix[i][i] = 0;
      }
  
      return new Graph(adjacencyMatrix);
  }  
  </code></pre>
  
  <p>Though, in some cases it fails to produce interval graph.</p>