Kolja Strohm il y a 6 ans
Parent
commit
0127535d1b

+ 18 - 1
doc/chapter/3progress.tex

@@ -1,9 +1,26 @@
 The following features are either planned (\planned), under construction (\progress) or done (\done):
 The following features are either planned (\planned), under construction (\progress) or done (\done):
 \begin{itemize}
 \begin{itemize}
     \item[\done] Reading from an input file as described in section~\ref{sec:inputFileFormat}.
     \item[\done] Reading from an input file as described in section~\ref{sec:inputFileFormat}.
+    \item[\done] Creating random graphs for testing purposes.
+    \begin{itemize}
+        \item[\done] Saving those randomly created graphs.
+    \end{itemize}
     \item[\done] Drawing a graph with specified node sizes and positions.
     \item[\done] Drawing a graph with specified node sizes and positions.
     \item[\progress] Running the node placement algorithm by Brandes and Köpf~\cite{brandes_fast_2001}.
     \item[\progress] Running the node placement algorithm by Brandes and Köpf~\cite{brandes_fast_2001}.
-    \item[\done] Illustrating the progress while the algorithm is running.
+    \begin{itemize}
+        \item[\done] Calculating the blocks.
+        \item[\progress] Compacting the layout.
+        \item[\planned] Combining the layouts.
+    \end{itemize}
+    \item[\progress] Illustrating the progress while the algorithm is running in the form of
+    \begin{itemize}
+        \item[\done] Drawing the nodes at their current position.
+        \item[\done] Drawing the nodes in the color of their blocks.
+        \item[\done] Drawing a colored circle to show the class assignments.
+        \item[\done] Drawing the edges just as plain straight lines.
+        \item[\progress] Drawing the four extremal layouts and the combined layout separately.
+        \item[\planned] Drawing the edges of the block graph (in a different color than other edges).
+    \end{itemize}
     \item[\done] Running the algorithm step by step manually (by pushing a button labeled \enquote{Step}).
     \item[\done] Running the algorithm step by step manually (by pushing a button labeled \enquote{Step}).
     \item[\progress] Running the algorithm step by step with configurable delay.
     \item[\progress] Running the algorithm step by step with configurable delay.
     \item[\planned] Using debugger-like commands such as \enquote{step into}, \enquote{step over}, \enquote{step out}.
     \item[\planned] Using debugger-like commands such as \enquote{step into}, \enquote{step over}, \enquote{step out}.

+ 2 - 4
doc/doc.bib

@@ -21,11 +21,9 @@
 	copyright = {MIT},
 	copyright = {MIT},
 	shorttitle = {{JSON}-java},
 	shorttitle = {{JSON}-java},
 	url = {https://github.com/stleary/JSON-java},
 	url = {https://github.com/stleary/JSON-java},
-	urldate = {2018-06-09},
 	author = {Leary, Sean and Crockford, Douglas},
 	author = {Leary, Sean and Crockford, Douglas},
 	month = jun,
 	month = jun,
-	year = {2018},
-	note = {original-date: 2010-12-21T17:46:09Z}
+	year = {2018}
 }
 }
 
 
 @article{sugiyama_methods_1981,
 @article{sugiyama_methods_1981,
@@ -39,7 +37,7 @@
 	author = {Sugiyama, K. and Tagawa, S. and Toda, M.},
 	author = {Sugiyama, K. and Tagawa, S. and Toda, M.},
 	month = feb,
 	month = feb,
 	year = {1981},
 	year = {1981},
-	keywords = {Computer displays, Constraint theory, Engineering drawings, Flowcharts, Hierarchical systems, Image recognition, Information science, Processor scheduling, Programming, Testing},
+	keywords = {Testing, Computer displays, Constraint theory, Engineering drawings, Flowcharts, Hierarchical systems, Image recognition, Information science, Processor scheduling, Programming},
 	pages = {109--125}
 	pages = {109--125}
 }
 }
 
 

+ 22 - 5
doc/zotero_backup/NodePlacementAnimation/NodePlacementAnimation.rdf

@@ -88,8 +88,6 @@
         </dc:identifier>
         </dc:identifier>
         <dc:rights>MIT</dc:rights>
         <dc:rights>MIT</dc:rights>
         <dc:date>2018-06-08T16:01:34Z</dc:date>
         <dc:date>2018-06-08T16:01:34Z</dc:date>
-        <dc:description>original-date: 2010-12-21T17:46:09Z</dc:description>
-        <dcterms:dateSubmitted>2018-06-09 01:27:34</dcterms:dateSubmitted>
         <z:libraryCatalog>GitHub</z:libraryCatalog>
         <z:libraryCatalog>GitHub</z:libraryCatalog>
         <z:programmingLanguage>Java</z:programmingLanguage>
         <z:programmingLanguage>Java</z:programmingLanguage>
         <dc:title>JSON-java: A reference implementation of a JSON package in Java</dc:title>
         <dc:title>JSON-java: A reference implementation of a JSON package in Java</dc:title>
@@ -120,6 +118,9 @@
                 </rdf:li>
                 </rdf:li>
             </rdf:Seq>
             </rdf:Seq>
         </bib:authors>
         </bib:authors>
+        <dc:subject>
+           <z:AutomaticTag><rdf:value>Testing</rdf:value></z:AutomaticTag>
+        </dc:subject>
         <dc:subject>
         <dc:subject>
             <z:AutomaticTag>
             <z:AutomaticTag>
                <rdf:value>Computer displays</rdf:value>
                <rdf:value>Computer displays</rdf:value>
@@ -161,9 +162,6 @@
         <dc:subject>
         <dc:subject>
            <z:AutomaticTag><rdf:value>Programming</rdf:value></z:AutomaticTag>
            <z:AutomaticTag><rdf:value>Programming</rdf:value></z:AutomaticTag>
         </dc:subject>
         </dc:subject>
-        <dc:subject>
-           <z:AutomaticTag><rdf:value>Testing</rdf:value></z:AutomaticTag>
-        </dc:subject>
         <bib:pages>109-125</bib:pages>
         <bib:pages>109-125</bib:pages>
         <dc:date>February 1981</dc:date>
         <dc:date>February 1981</dc:date>
         <z:libraryCatalog>IEEE Xplore</z:libraryCatalog>
         <z:libraryCatalog>IEEE Xplore</z:libraryCatalog>
@@ -177,4 +175,23 @@
         <dc:identifier>ISSN 0018-9472</dc:identifier>
         <dc:identifier>ISSN 0018-9472</dc:identifier>
         <dc:identifier>DOI 10.1109/TSMC.1981.4308636</dc:identifier>
         <dc:identifier>DOI 10.1109/TSMC.1981.4308636</dc:identifier>
     </bib:Journal>
     </bib:Journal>
+    <bib:Data rdf:about="https://github.com/eclipse/elk">
+        <z:itemType>computerProgram</z:itemType>
+        <dc:publisher>
+            <foaf:Organization>
+               <foaf:name>Eclipse Foundation</foaf:name>
+            </foaf:Organization>
+        </dc:publisher>
+        <dc:identifier>
+            <dcterms:URI>
+               <rdf:value>https://github.com/eclipse/elk</rdf:value>
+            </dcterms:URI>
+        </dc:identifier>
+        <dc:rights>EPL-1.0</dc:rights>
+        <dc:date>2018-06-09T11:09:35Z</dc:date>
+        <z:libraryCatalog>GitHub</z:libraryCatalog>
+        <z:programmingLanguage>Java</z:programmingLanguage>
+        <dc:title>ELK: Eclipse Layout Kernel - Automatic layout for Java applications</dc:title>
+        <z:shortTitle>ELK</z:shortTitle>
+    </bib:Data>
 </rdf:RDF>
 </rdf:RDF>

+ 67 - 42
src/Algorithms/Animated/BK/Compaction.java

@@ -31,8 +31,8 @@ public class Compaction implements AlgorithmStage{
 	private LayeredGraphNode graph;
 	private LayeredGraphNode graph;
 	private int vIndex;
 	private int vIndex;
 	
 	
-	private ArrayList< StackFrame > stack;
-	private ArrayList< BackwardAction > actions;
+	private ArrayList< StackFrame > stack; // TODO: evtl richtigen "Stack" benutzen
+	private ArrayList< BackwardAction > actions; // TODO: evtl richtigen "Stack" benutzen
 	private LayoutType layout;
 	private LayoutType layout;
 	
 	
 	public Compaction( LayeredGraphNode graph, LayoutType layout )
 	public Compaction( LayeredGraphNode graph, LayoutType layout )
@@ -40,7 +40,7 @@ public class Compaction implements AlgorithmStage{
 	    this.layout = layout;
 	    this.layout = layout;
 		this.graph = graph;
 		this.graph = graph;
 		state = CompactionState.PLACE_BLOCKS;
 		state = CompactionState.PLACE_BLOCKS;
-		stack = new ArrayList<>();
+		stack = new ArrayList<>(); // der call-stack des rekursiven algorithmus
 		vIndex = 0;
 		vIndex = 0;
 		actions = new ArrayList<>();
 		actions = new ArrayList<>();
 	}
 	}
@@ -69,13 +69,15 @@ public class Compaction implements AlgorithmStage{
 	@Override
 	@Override
 	public StageStatus forwardStep() {
 	public StageStatus forwardStep() {
 		int acSize = actions.size();
 		int acSize = actions.size();
-		if( state == CompactionState.PLACE_BLOCKS )
+		if( state == CompactionState.PLACE_BLOCKS ) // blöcke platzieren
 		{
 		{
-			if( stack.size() == 0 )
+			if( stack.size() == 0 ) // äußere schleife, placeblocks bisher nicht aufgerufen
 			{
 			{
 				ArrayList< LayeredGraphNode > nodes = graph.getContainedNodes();
 				ArrayList< LayeredGraphNode > nodes = graph.getContainedNodes();
-				boolean found = false;
-				int oldVIndex = vIndex;
+				boolean found = false; // knoten mit v = root[v] gefunden?
+				int oldVIndex = vIndex; // nötig für "undo"
+				
+				// suche knoten mit v = root[v] und undefiniertem x-Wert
 				for( ; vIndex < nodes.size(); vIndex++ )
 				for( ; vIndex < nodes.size(); vIndex++ )
 				{
 				{
 					if( getNodeFromIndex( vIndex ).isXUndefined( layout ) && getNodeFromIndex( vIndex ) == getNodeFromIndex( vIndex ).getRoot( layout ) )
 					if( getNodeFromIndex( vIndex ).isXUndefined( layout ) && getNodeFromIndex( vIndex ) == getNodeFromIndex( vIndex ).getRoot( layout ) )
@@ -84,8 +86,11 @@ public class Compaction implements AlgorithmStage{
 						break;
 						break;
 					}
 					}
 				}
 				}
+				
+				// kein knoten gefunden
 				if( !found )
 				if( !found )
 				{
 				{
+				    // wechsele in die phase des Blöckeshiftens
 					state = CompactionState.APPLY_SHIFT;
 					state = CompactionState.APPLY_SHIFT;
 					vIndex = 0;
 					vIndex = 0;
 					actions.add( 0, ()-> {
 					actions.add( 0, ()-> {
@@ -93,16 +98,18 @@ public class Compaction implements AlgorithmStage{
 						state = CompactionState.PLACE_BLOCKS;
 						state = CompactionState.PLACE_BLOCKS;
 					} );
 					} );
 				}
 				}
-				else
+				else // Knoten gefunden
 				{
 				{
-					StackFrame f = new StackFrame();
+					StackFrame f = new StackFrame(); // enthält lokale variablen
 					f.v = getNodeFromIndex( vIndex );
 					f.v = getNodeFromIndex( vIndex );
-					double oldX = f.v.getX( layout );
+					double oldX = f.v.getX( layout ); // nötig für "undo"
 					f.v.setX( 0, true, layout );
 					f.v.setX( 0, true, layout );
-					f.v.setSelected( layout );
+					f.v.setSelected( layout ); // zeige knoten als aktiven knoten an
 					f.w = f.v;
 					f.w = f.v;
                     System.out.println( "call place_block( " + f.v + " )" );
                     System.out.println( "call place_block( " + f.v + " )" );
 					stack.add( 0, f );
 					stack.add( 0, f );
+					
+					// die "undo"-action
 					actions.add( 0, ()-> {
 					actions.add( 0, ()-> {
 						stack.get( 0 ).v.setX( oldX, false, layout );
 						stack.get( 0 ).v.setX( oldX, false, layout );
 						stack.get( 0 ).v.setSelected( layout );
 						stack.get( 0 ).v.setSelected( layout );
@@ -112,25 +119,29 @@ public class Compaction implements AlgorithmStage{
 					});
 					});
 				}
 				}
 			}
 			}
-			else
+			else // zurzeit innerhalb einer placeblock methode
 			{
 			{
 				StackFrame sf = stack.get( 0 );
 				StackFrame sf = stack.get( 0 );
-				if( sf.u == null )
+				if( sf.u == null ) // zu beginn der placeblock methode
 				{
 				{
-				    int posW = graph.getContainedLayers().get( sf.w.getLayer() ).indexOf( sf.w );
-					if( posW >= 1 )
+                    int posW = graph.getContainedLayers().get( sf.w.getLayer() ).indexOf( sf.w );
+					if( posW >= 1 ) // if pos[w] > 1"
 					{
 					{
-						sf.u = graph.getContainedLayers().get( sf.w.getLayer() ).get( posW - 1 ).getRoot( layout );
-						if( sf.u.isXUndefined( layout ) )
-						{
-							StackFrame nsf = new StackFrame();
+
+                        sf.u = graph.getContainedLayers().get( sf.w.getLayer() ).get( posW - 1 ).getRoot( layout );
+						
+						if( sf.u.isXUndefined( layout ) ) // nötig placeblock aufzurufen?
+						{// ja
+							StackFrame nsf = new StackFrame(); // enthält lokale variablen
 							nsf.v = sf.u;
 							nsf.v = sf.u;
-							double oldX = nsf.v.getX( layout );
+							double oldX = nsf.v.getX( layout ); // nötig für "undo"
 							nsf.v.setX( 0, true, layout );
 							nsf.v.setX( 0, true, layout );
-							nsf.v.setSelected( layout );
+							nsf.v.setSelected( layout ); // zeige knoten als aktiven knoten an
 							nsf.w = nsf.v;
 							nsf.w = nsf.v;
 		                    System.out.println( "call place_block( " + nsf.v + " )" );
 		                    System.out.println( "call place_block( " + nsf.v + " )" );
 							stack.add( 0, nsf );
 							stack.add( 0, nsf );
+		                    
+		                    // die "undo"-action
 							actions.add( 0, ()-> {
 							actions.add( 0, ()-> {
 								stack.get( 0 ).v.setX( oldX, false, layout );
 								stack.get( 0 ).v.setX( oldX, false, layout );
 								stack.get( 0 ).v.setSelected( layout );
 								stack.get( 0 ).v.setSelected( layout );
@@ -138,22 +149,23 @@ public class Compaction implements AlgorithmStage{
 								stack.get( 0 ).u = null;
 								stack.get( 0 ).u = null;
 							});
 							});
 						}
 						}
-						else
+						else // nein
 						{
 						{
-							sf.u.setSelected( layout );
+						    // tue nix
+							sf.u.setSelected( layout ); 
 							actions.add( 0, ()-> {
 							actions.add( 0, ()-> {
 								stack.get( 0 ).u = null;
 								stack.get( 0 ).u = null;
 							});
 							});
 						}
 						}
 					}
 					}
-					else
-					{
+					else 
+					{ // w = align[w]
 						LayeredGraphNode oldW = sf.w;
 						LayeredGraphNode oldW = sf.w;
 						sf.v.setSelected( layout );
 						sf.v.setSelected( layout );
 						sf.w = sf.w.getAlignedTo( layout );
 						sf.w = sf.w.getAlignedTo( layout );
-						if( sf.w == sf.v )
-						{
-		                    System.out.println( "return place_block( " + sf.v + " )" );
+						if( sf.w == sf.v ) // schleifenabbruchbedingung
+						{ //abbrechen, placeblock beendet
+                            System.out.println( "return place_block( " + sf.v + " )" );
 							stack.remove( 0 );
 							stack.remove( 0 );
 							actions.add( 0, ()-> {
 							actions.add( 0, ()-> {
 								stack.add( 0, sf );
 								stack.add( 0, sf );
@@ -162,7 +174,7 @@ public class Compaction implements AlgorithmStage{
 							});
 							});
 						}
 						}
 						else
 						else
-						{
+						{ //nur "undo aktion" hinzufügen
 							actions.add( 0, ()-> {
 							actions.add( 0, ()-> {
 								sf.w = oldW;
 								sf.w = oldW;
 								sf.v.setSelected( layout );
 								sf.v.setSelected( layout );
@@ -170,27 +182,40 @@ public class Compaction implements AlgorithmStage{
 						}
 						}
 					}	
 					}	
 				}
 				}
-				else
+				else // der Teil nach "placeBlock(u)", genannt "absolute coordinates"
 				{
 				{
-					LayeredGraphNode oldSink = sf.v.getSink( layout );
+				    // alte Werte merken für undo
+					LayeredGraphNode oldSink = sf.v.getSink( layout );	
 					LayeredGraphNode sinkOfU = sf.u.getSink( layout );
 					LayeredGraphNode sinkOfU = sf.u.getSink( layout );
 					double oldShift = sinkOfU.getShift( layout );
 					double oldShift = sinkOfU.getShift( layout );
 					double oldX = sf.v.getX( layout );
 					double oldX = sf.v.getX( layout );
 					boolean oldDef = !sf.v.isXUndefined( layout );
 					boolean oldDef = !sf.v.isXUndefined( layout );
+					
+					// v für visualisierung markieren
 					sf.v.setSelected( layout );
 					sf.v.setSelected( layout );
-                    if( sf.v.getSink( layout ) == sf.v )
-                        sf.v.setSink( sf.u.getSink( layout ), layout );
-					if( sf.v.getSink( layout ) != sf.u.getSink( layout ) )
-						sf.u.getSink( layout ).setShift( Math.min( sf.u.getSink( layout ).getShift( layout ), sf.v.getX( layout ) - sf.u.getX( layout ) - calcSpacing() ), layout );
+                    
+                    if( sf.v.getSink( layout ) == sf.v ) // sink[v] = v?
+                        sf.v.setSink( sf.u.getSink( layout ), layout ); // sink[v] := sink[u]
+
+					if( sf.v.getSink( layout ) != sf.u.getSink( layout ) ) // sink[v] != sink [u]?
+						sf.u.getSink( layout ).setShift( // shift[sink[u]] =
+						  Math.min( sf.u.getSink( layout ).getShift( layout ),  // min(shift[sink[u]]
+						          sf.v.getX( layout ) - sf.u.getX( layout ) - calcSpacing() ), layout ); // y_v - y_u - s
 					else
 					else
+					    // y_v = max {y_v, y_u + s}
 						sf.v.setX( Math.max( sf.v.getX( layout ), sf.u.getX( layout ) + calcSpacing() ), true, layout );
 						sf.v.setX( Math.max( sf.v.getX( layout ), sf.u.getX( layout ) + calcSpacing() ), true, layout );
+					
+
+                    // alte Werte merken für undo
 					LayeredGraphNode oldW = sf.w;
 					LayeredGraphNode oldW = sf.w;
-					sf.w = sf.w.getAlignedTo( layout );
-					LayeredGraphNode oldU = sf.u;
-					sf.u = null;
-					if( sf.w == sf.v )
-					{
-                        System.out.println( "return place_block( " + sf.v + " )" );
+                    LayeredGraphNode oldU = sf.u;
+                    
+					sf.w = sf.w.getAlignedTo( layout ); // w = align[w]
+					sf.u = null; // u wird nächsten schleifendurchlauf neu gesetzt
+					
+					if( sf.w == sf.v ) // schleifenabbruchbedingung
+					{ //abbrechen, placeblock beendet  
+					    System.out.println( "return place_block( " + sf.v + " )" );
 						stack.remove( 0 );
 						stack.remove( 0 );
 						actions.add( 0, ()-> {
 						actions.add( 0, ()-> {
 							stack.add( 0, sf );
 							stack.add( 0, sf );
@@ -203,7 +228,7 @@ public class Compaction implements AlgorithmStage{
 						});
 						});
 					}
 					}
 					else
 					else
-					{
+					{ //nur "undo aktion" hinzufügen
 						actions.add( 0, ()-> {
 						actions.add( 0, ()-> {
 							stack.get( 0 ).v.setSink(  oldSink, layout );
 							stack.get( 0 ).v.setSink(  oldSink, layout );
 							sinkOfU.setShift( oldShift, layout );
 							sinkOfU.setShift( oldShift, layout );