use of org.cytoscape.filter.internal.quickfind.util.QuickFindImpl in project cytoscape-impl by cytoscape.
the class PerformanceScaffold method main.
public static void main(String[] args) {
NetworkTestSupport testSupport = new NetworkTestSupport();
CyNetwork network = testSupport.getNetwork();
CyTable nodeTable = network.getDefaultNodeTable();
nodeTable.createColumn(STRING_COLUMN, String.class, false);
nodeTable.createColumn(INTEGER_COLUMN, Integer.class, false);
nodeTable.createListColumn(LIST_STRING_COLUMN, String.class, false);
// Use a fixed set of string attributes.
// Worst case performance for trie expected for first entry
// Best case performance expected for last entry
Random random = new Random(1);
String[] values = { "AAAAAAAAAAAAAAA", "AAAAAAAAAAAAAAB", "AAAAAAAAAAAAACA", "AAAAAAAAAAAADAA", "AAAAAAAAAAAEAAA", "AAAAAAAAAAFAAAA", "AAAAAAAAAGAAAAA", "AAAAAAAAHAAAAAA", "AAAAAAAIAAAAAAA", "AAAAAAJAAAAAAAA", "AAAAAKAAAAAAAAA", "AAAALAAAAAAAAAA", "AAAMAAAAAAAAAAA", "AANAAAAAAAAAAAA", "AOAAAAAAAAAAAAA", "PAAAAAAAAAAAAAA" };
int totalNodes = TOTAL_NODES;
int totalEdges = totalNodes * AVERAGE_EDGES_PER_NODE;
long start;
start = System.currentTimeMillis();
List<CyNode> nodes = new ArrayList<CyNode>();
for (int i = 0; i < totalNodes; i++) {
CyNode node = network.addNode();
int valueIndex = random.nextInt(values.length);
network.getRow(node).set(STRING_COLUMN, values[valueIndex]);
network.getRow(node).set(INTEGER_COLUMN, valueIndex);
network.getRow(node).set(LIST_STRING_COLUMN, Collections.singletonList(values[valueIndex]));
nodes.add(node);
}
// Construct random graph
for (int i = 0; i < totalEdges; i++) {
CyNode source = nodes.get(random.nextInt(totalNodes));
CyNode target = nodes.get(random.nextInt(totalNodes));
network.addEdge(source, target, true);
}
System.out.printf("Construct\t%d\n", System.currentTimeMillis() - start);
TransformerManagerImpl transformerManager = new TransformerManagerImpl();
Map<String, String> properties = Collections.emptyMap();
transformerManager.registerTransformerSource(new CyNetworkSource(), properties);
List<UseCase> useCases = new ArrayList<UseCase>();
QuickFind quickFind = new QuickFindImpl();
useCases.add(new NumberAttributeUseCase(quickFind, 0, transformerManager));
useCases.add(new StringAttributeUseCase(quickFind, values[values.length - 1], transformerManager));
useCases.add(new DegreeUseCase(3, transformerManager));
for (UseCase useCase : useCases) {
useCase.execute(network, ITERATIONS);
}
}
Aggregations