src/Pure/General/graph.scala
changeset 46668 9034b44844bd
parent 46667 318b669fe660
child 46712 8650d9a95736
equal deleted inserted replaced
46667:318b669fe660 46668:9034b44844bd
   117 
   117 
   118   def is_minimal(x: Key): Boolean = imm_preds(x).isEmpty
   118   def is_minimal(x: Key): Boolean = imm_preds(x).isEmpty
   119   def is_maximal(x: Key): Boolean = imm_succs(x).isEmpty
   119   def is_maximal(x: Key): Boolean = imm_succs(x).isEmpty
   120 
   120 
   121 
   121 
   122   /* nodes */
   122   /* node operations */
   123 
   123 
   124   def new_node(x: Key, info: A): Graph[Key, A] =
   124   def new_node(x: Key, info: A): Graph[Key, A] =
   125   {
   125   {
   126     if (rep.isDefinedAt(x)) throw new Graph.Duplicate(x)
   126     if (rep.isDefinedAt(x)) throw new Graph.Duplicate(x)
   127     else new Graph[Key, A](rep + (x -> (info, (empty_keys, empty_keys))))
   127     else new Graph[Key, A](rep + (x -> (info, (empty_keys, empty_keys))))
   150 
   150 
   151   def restrict(pred: Key => Boolean): Graph[Key, A] =
   151   def restrict(pred: Key => Boolean): Graph[Key, A] =
   152     (this /: entries){ case (graph, (x, _)) => if (!pred(x)) graph.del_node(x) else graph }
   152     (this /: entries){ case (graph, (x, _)) => if (!pred(x)) graph.del_node(x) else graph }
   153 
   153 
   154 
   154 
   155   /* edges */
   155   /* edge operations */
   156 
   156 
   157   def is_edge(x: Key, y: Key): Boolean =
   157   def is_edge(x: Key, y: Key): Boolean =
   158     try { imm_succs(x)(y) }
   158     try { imm_succs(x)(y) }
   159     catch { case _: Graph.Undefined[_] => false }
   159     catch { case _: Graph.Undefined[_] => false }
   160 
   160