org.wicketstuff.datatable_autocomplete.tree.TSTGraph Maven / Gradle / Ivy
                 Go to download
                
        
                    Show more of this group  Show more artifacts with this name
Show all versions of datatable-autocomplete-test Show documentation
                Show all versions of datatable-autocomplete-test Show documentation
Test code for visualizing a Trie.  Seperated so that projects can use the JUNG visualization against their actual production data
                
             The newest version!
        
        /*
 * 
 * ==============================================================================
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package org.wicketstuff.datatable_autocomplete.tree;
import org.wicketstuff.datatable_autocomplete.tst.TernaryNode;
import org.wicketstuff.datatable_autocomplete.tst.TernaryNodeVisitor;
import org.wicketstuff.datatable_autocomplete.tst.TernarySearchTrie;
import edu.uci.ics.jung.graph.DirectedSparseMultigraph;
/**
 * @author mocleiri
 * 
 *         A JUNG graph to represent the TernarySearchTrie
 * 
 */
public class TSTGraph extends DirectedSparseMultigraph, String>
{
	private static final long serialVersionUID = 1L;
	/**
	 * @param order
	 */
	public TSTGraph(TernarySearchTrie trie)
	{
		super();
		TernaryNode rootNode = trie.getRoot();
		addVertex(rootNode);
		buildNode(rootNode);
	}
	private void buildNode(TernaryNode node)
	{
		node.visit(new TernaryNodeVisitor()
		{
			private static final long serialVersionUID = 1L;
			/*
			 * (non-Javadoc)
			 * 
			 * @see org.wicketstuff.datatable_autocomplete.tst.TernaryNodeVisitor#postVisit()
			 */
			public void postVisit()
			{
				// TODO Auto-generated method stub
			}
			/*
			 * (non-Javadoc)
			 * 
			 * @see org.wicketstuff.datatable_autocomplete.tst.TernaryNodeVisitor#preVisit()
			 */
			public void preVisit()
			{
				// TODO Auto-generated method stub
			}
			/*
			 * (non-Javadoc)
			 * 
			 * @see
			 * org.wicketstuff.datatable_autocomplete.tst.TernaryNodeVisitor#visit(org.wicketstuff
			 * .datatable_autocomplete.tst.TernaryNode)
			 */
			public void visit(TernaryNode node)
			{
				TernaryNode parent = node.getParentNode();
				if (parent != null)
				{
					addEdge("", node.getParentNode(), node);
				}
				node.visit(this);
			}
		});
	}
}
            © 2015 - 2025 Weber Informatics LLC | Privacy Policy