clarified signature;
authorwenzelm
Fri, 23 Mar 2018 21:56:22 +0100
changeset 67935 61888dd27f73
parent 67934 5b0636910618
child 67936 141a93b93aa6
clarified signature;
src/Pure/General/graph.scala
--- a/src/Pure/General/graph.scala	Fri Mar 23 20:45:46 2018 +0100
+++ b/src/Pure/General/graph.scala	Fri Mar 23 21:56:22 2018 +0100
@@ -20,13 +20,14 @@
   def empty[Key, A](implicit ord: Ordering[Key]): Graph[Key, A] =
     new Graph[Key, A](SortedMap.empty(ord))
 
-  def make[Key, A](entries: List[((Key, A), List[Key])])(
+  def make[Key, A](entries: List[((Key, A), List[Key])], symmetric: Boolean = false)(
     implicit ord: Ordering[Key]): Graph[Key, A] =
   {
     val graph1 =
       (empty[Key, A](ord) /: entries) { case (graph, ((x, info), _)) => graph.new_node(x, info) }
     val graph2 =
-      (graph1 /: entries) { case (graph, ((x, _), ys)) => (graph /: ys)(_.add_edge(x, _)) }
+      (graph1 /: entries) { case (graph, ((x, _), ys)) =>
+        (graph /: ys)({ case (g, y) => if (symmetric) g.add_edge(y, x) else g.add_edge(x, y) }) }
     graph2
   }