Changes for page KLay Layered
Last modified by Richard Kreissig on 2023/09/14 09:07
Summary
-
Page properties (1 modified, 0 added, 0 removed)
-
Objects (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -1,19 +1,5 @@ 1 -In this tutorial you'll learn about the structure and philosoph iein our main layout algorithm [[doc:KIELER.KLay Layered]]. It is based on an idea that became known as //Sugiyama-style// layout, where the task to layout a graph is split into multiple subsequent steps with the goal to emphasize direction, i.e. let as many edges point into the same direction as possible.1 +In this tutorial you'll learn about the structure and philosophy in our main layout algorithm [[doc:KIELER.KLay Layered]]. It is based on an idea that became known as //Sugiyama-style// layout, where the task to layout a graph is split into multiple subsequent steps with the goal to emphasize direction, i.e. let as many edges point into the same direction as possible. 2 2 3 - 4 - 5 -= The Five Phases = 6 - 7 -explain 8 - 9 -= KLay Layered's Structure = 10 - 11 -class diagram? 12 - 13 -Intermediate processor 14 - 15 - 16 - 17 17 = Preliminaries = 18 18 19 19 [[doc:Installing Eclipse for Layout Development]] ... ... @@ -27,18 +27,38 @@ 27 27 1. Clone the [[repository>>url:http://git.rtsys.informatik.uni-kiel.de/projects/KIELER/repos/pragmatics/browse||shape="rect"]]. 28 28 1. Import the {{code language="none"}}de.cau.cs.kieler.klay.layered{{/code}} plugin into your workspace. 29 29 30 - 16 += Getting to Know KLay Layered = 31 31 18 +1. Familiarize yourself with the general idea and architecture of the layout algorithm by reading its [[documentation>>doc:KIELER.KLay Layered]]. You should know about terms like //dummy nodes//, //intermediate processors//, and //phases//. 19 +1. With this knowledge, browse the code and try to identify the packages and classes that relate to the phases of KLay Layered. 20 +1. Understand the differences between the {{code language="none"}}KGraph{{/code}} and {{code language="none"}}LGraph{{/code}} and explore how to use the {{code language="none"}}LGraph{{/code}}. As noted in KLay Layered's documentation the {{code language="none"}}LGraph{{/code}} is a lightweight version that is specifically tailored to serve as a data structure for layer-based layout. 21 + 32 32 = Assignment = 33 33 34 -The goal of this assignment is to write a very simple layering algorithm. As you learntearlier, classically the layering phase expects the input graph to be acyclic. Here however, you willconfigure the layout algorithm to use a {{code language="none"}}NullPhase{{/code}} for cycle breaking, layer the possibly cyclic graph in a fashion as you like, and use an intermediate processor to reverse edges (if required) such that subsequent phases are guaranteed to work with an acyclic graph.24 +The goal of this assignment is to write a very simple layering algorithm. As you probably already know, classically the layering phase (phase 2) expects the input graph to be acyclic. Here however, you will: 35 35 26 +1. Configure the layout algorithm to use a {{code language="none"}}NullPhase{{/code}} for cycle breaking, 27 +1. Layer the possibly cyclic graph in a fashion as you like, and 28 +1. Use an intermediate processor to reverse edges (if required) such that subsequent phases are guaranteed to work with an acyclic graph. 29 + 30 +Don't hesitate to switch between the tasks and don't be afraid of exceptions or errors during debugging. When you use your layering phase without the intermediate processors the rest of KLay Layered will most likely complain (for cyclic input graphs). In other words, the following two assignments only work combined and not alone. 31 + 36 36 {{panel title="Assignment (1)"}} 37 37 Write an intermediate processor that takes a //layered// graph as input and reverses edges such that the output graph is acyclic. Here are some hints. 38 38 39 -The {{code language="none"}}LEdge{{/code}} offers a method {{code language="none"}}reverseEdge{{/code}} that does most of the job for you and marks the edge. The {{code language="none"}} EdgeReversalRestorer{{/code}}35 +The {{code language="none"}}LEdge{{/code}} offers a method {{code language="none"}}reverseEdge{{/code}} that does most of the job for you and marks the edge. The {{code language="none"}}ReversedEdgeRestorer {{/code}}will take care of 'back'-reversing such edges at the end of the algorithm. Your class should extend the {{code language="none"}}ILayoutProcessor{{/code}} interface. 40 40 41 -CODE 37 +{{code linenumbers="true" language="java"}} 38 +public class EdgeDirectionEnforcer implements ILayoutProcessor { 39 + @Override 40 + public void process(final LGraph layeredGraph, final IKielerProgressMonitor progressMonitor) { 41 + // for all edges ... 42 + if (...) { 43 + edge.reverse(layeredGraph, true); 44 + } 45 + } 46 +} 47 +{{/code}} 42 42 {{/panel}} 43 43 44 44 {{panel title="Assignment (2)"}} ... ... @@ -46,7 +46,29 @@ 46 46 47 47 The intermediate processing configuration has to include your previously created intermediate processor as well as the mentioned edge reverser. 48 48 49 - CODE55 +Take care not to place two nodes in the same layer if they are connected by an edge. 50 50 51 - 57 +{{code linenumbers="true" language="java"}} 58 +public class RandomLayerer implements ILayoutPhase { 59 + @Override 60 + public IntermediateProcessingConfiguration getIntermediateProcessingConfiguration(final LGraph graph) { 61 + return IntermediateProcessingConfiguration.createEmpty() 62 + [ ... ] // add your desired configuration here 63 + ; 64 + } 65 + 66 + @Override 67 + public void process(final LGraph layeredGraph, final IKielerProgressMonitor progressMonitor) { 68 + [ ... ] 69 + } 70 +} 71 +{{/code}} 52 52 {{/panel}} 73 + 74 + 75 + 76 +A result might look like this. The default strategies of KLay Layered try to achieve short edges and a low number of reversed edges. The left screenshot shows the result of a random layerer and is obviously inferior to the result seen in the right screenshot. 77 + 78 + 79 + 80 +[[image:attach:rand.jpg]][[image:attach:klay.jpg]]
- Confluence.Code.ConfluencePageClass[0]
-
- Id
-
... ... @@ -1,1 +1,1 @@ 1 -107517 261 +10751754 - URL
-
... ... @@ -1,1 +1,1 @@ 1 -https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/TUT/pages/107517 26/KLay Layered1 +https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/TUT/pages/10751754/KLay Layered