Changeset 30 for trunk/EventBenchCore/src/de/ugoe/cs/eventbench
- Timestamp:
- 04/14/11 16:09:27 (14 years ago)
- Location:
- trunk/EventBenchCore/src/de/ugoe/cs/eventbench/models
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/EventBenchCore/src/de/ugoe/cs/eventbench/models/Trie.java
r23 r30 6 6 import java.util.Set; 7 7 8 import de.ugoe.cs.util.StringTools; 9 8 10 import edu.uci.ics.jung.graph.DelegateTree; 9 11 import edu.uci.ics.jung.graph.Tree; 10 12 11 public class Trie<T> {13 public class Trie<T> implements IDotCompatible { 12 14 13 15 private Set<T> knownSymbols; … … 148 150 } 149 151 152 public String getDotRepresentation() { 153 StringBuilder stringBuilder = new StringBuilder(); 154 stringBuilder.append("digraph model {" + StringTools.ENDLINE); 155 rootNode.appendDotRepresentation(stringBuilder); 156 stringBuilder.append('}' + StringTools.ENDLINE); 157 return stringBuilder.toString(); 158 } 159 150 160 @Override 151 161 public String toString() { -
trunk/EventBenchCore/src/de/ugoe/cs/eventbench/models/TrieBasedModel.java
r23 r30 73 73 } 74 74 75 public String getTrieDotRepresentation() { 76 return trie.getDotRepresentation(); 77 } 78 75 79 public Tree<TrieVertex, Edge> getTrieGraph() { 76 80 return trie.getGraph(); -
trunk/EventBenchCore/src/de/ugoe/cs/eventbench/models/TrieNode.java
r13 r30 26 26 public TrieNode(T symbol) { 27 27 if( symbol==null ) { 28 throw new InvalidParameterException("symbol must not be null. ");28 throw new InvalidParameterException("symbol must not be null. null is reserved for root node!"); 29 29 } 30 30 this.symbol = symbol; … … 120 120 } 121 121 } 122 122 123 void appendDotRepresentation(StringBuilder stringBuilder) { 124 String thisSaneId; 125 if( symbol==null ) { 126 thisSaneId = "root"; 127 } else { 128 thisSaneId = symbol.toString().replace("\"", "\\\"").replaceAll("[\r\n]","")+"#"+count; 129 } 130 stringBuilder.append(" " + hashCode() + " [label=\""+thisSaneId+"\"];" + StringTools.ENDLINE); 131 for( TrieNode<T> childNode : children ) { 132 stringBuilder.append(" "+hashCode()+" -> " + childNode.hashCode() + ";" + StringTools.ENDLINE); 133 } 134 for( TrieNode<T> childNode : children ) { 135 childNode.appendDotRepresentation(stringBuilder); 136 } 137 } 123 138 }
Note: See TracChangeset
for help on using the changeset viewer.