org.wicketstuff.datatable_autocomplete.tree.TrieGraph 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 java.util.List;
import java.util.concurrent.atomic.AtomicLong;
import org.wicketstuff.datatable_autocomplete.trie.PatriciaTrie;
import org.wicketstuff.datatable_autocomplete.trie.TrieNode;
import edu.uci.ics.jung.graph.DirectedSparseMultigraph;
/**
 * @author mocleiri
 * 
 */
public class TrieGraph extends DirectedSparseMultigraph, String>
{
	private static final long serialVersionUID = 1L;
	private final AtomicLong counter = new AtomicLong();
	/**
	 * @param order
	 */
	public TrieGraph(PatriciaTrie trie)
	{
		super();
		addVertex(trie.getRoot());
		buildGraph(trie.getRoot());
	}
	private void buildGraph(TrieNode root)
	{
		List> nodeList = root.getOrderedNodeList();
		for (TrieNode trieNode : nodeList)
		{
			addEdge(String.valueOf(counter.addAndGet(1)), root, trieNode);
			buildGraph(trieNode);
		}
	}
}
          © 2015 - 2025 Weber Informatics LLC | Privacy Policy