scala: data structure for multiple-root tree or forest
<p>I am in search of a good data structure for my requirement:</p>

<ul>
<li>Support multiple roots.</li>
<li>Should have links to parent and children.</li>
</ul>

<p>Assuming each <code>Node</code> can be uniquely identified, I have come up with a following data structure which seems a bit immature.</p>

<pre><code>case class Node[T](data: T, children: List[Node[T]], parents: List[Node[T]])

class Forest[T](val roots: List[Node[T]]) {

  // other helper methods to create the Forest
}

object Forest {
  def apply[T](list: List[T]): Forest[T] = {
    val roots = for (l &lt;- list) yield Node[T](l, List.empty[Node[T]], List.empty[Node[T]])
    new Forest[T](roots)
  }
}
</code></pre>

<p>Does anyone have better suggestions?</p>

<p>TIA</p>