I use the traversal of a tree (BFS and DFS) in a JPNL BFS (): Any thoughts? Thanks! For example, you can type and in the timer, at fixed delays, timer and
Paint Component ... similarly ...
Public Zero BFS () {QQ = New Linkedist (); Q.add (rootNode); RootNode.visited (true); RootNode.setColor (Color.cyan); PrintNode (rootNode); // only when counter = 10 checks; While (! Q.isEmpty ()) {nodes n = (nodes) q.remove (); Nodes child = null; // while putting all unvisited children in the queue ((child = getUnvisitedChildNode (n)) = tap) {if (counter == 3) {child.visited (true); PrintNode (child); Q.add (child); Child.setColor (Color.cyan); }}} If (q.isEmpty ()) {Cancel timer = true; //RepaintManagerCurrentManager(this).markCompletelyClean(this); }}
queue < Nodes & gt; which will accept nodes for painting. That is, in your
bfs () method, where you set the color
child.setColor (Color.cyan); Add this node to a
cue . Therefore:
if (counter == 3) {child.visited (true); PrintNode (child); Q.add (child); PaintQueue.add (child); }
poll this line and node color:
timer.scheduleAtFixedRate (new timer Task () {Public Zero Run (if (PaintQQ.ISEplay ()) {nodes node = PentUQUP (.); Node.Setterang (color.);}}}, Initial del, 1000);
No comments:
Post a Comment