src/Tools/Graphview/layout.scala
changeset 75394 42267c650205
parent 75393 87ebf5a50283
child 75403 0f80086c000e
equal deleted inserted replaced
75393:87ebf5a50283 75394:42267c650205
   193     options: Options,
   193     options: Options,
   194     graph: Graph,
   194     graph: Graph,
   195     levels: List[Level]
   195     levels: List[Level]
   196   ): List[Level] = {
   196   ): List[Level] = {
   197     def resort(parent: Level, child: Level, top_down: Boolean): Level =
   197     def resort(parent: Level, child: Level, top_down: Boolean): Level =
   198       child.map(v => {
   198       child.map({ v =>
   199         val ps = if (top_down) graph.imm_preds(v) else graph.imm_succs(v)
   199         val ps = if (top_down) graph.imm_preds(v) else graph.imm_succs(v)
   200         val weight =
   200         val weight =
   201           ps.foldLeft(0.0) { case (w, p) => w + (0 max parent.indexOf(p)) } / (ps.size max 1)
   201           ps.foldLeft(0.0) { case (w, p) => w + (0 max parent.indexOf(p)) } / (ps.size max 1)
   202         (v, weight)
   202         (v, weight)
   203       }).sortBy(_._2).map(_._1)
   203       }).sortBy(_._2).map(_._1)