src/Pure/General/graph.scala
changeset 67935 61888dd27f73
parent 67018 f6aa133f9b16
child 68321 daca5f2a0c90
--- 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
   }