Search in sources :

Example 1 with QuickFindImpl

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);
    }
}
Also used : NetworkTestSupport(org.cytoscape.model.NetworkTestSupport) ArrayList(java.util.ArrayList) CyNetwork(org.cytoscape.model.CyNetwork) QuickFindImpl(org.cytoscape.filter.internal.quickfind.util.QuickFindImpl) CyTable(org.cytoscape.model.CyTable) Random(java.util.Random) QuickFind(org.cytoscape.filter.internal.quickfind.util.QuickFind) CyNode(org.cytoscape.model.CyNode) TransformerManagerImpl(org.cytoscape.filter.internal.work.TransformerManagerImpl)

Aggregations

ArrayList (java.util.ArrayList)1 Random (java.util.Random)1 QuickFind (org.cytoscape.filter.internal.quickfind.util.QuickFind)1 QuickFindImpl (org.cytoscape.filter.internal.quickfind.util.QuickFindImpl)1 TransformerManagerImpl (org.cytoscape.filter.internal.work.TransformerManagerImpl)1 CyNetwork (org.cytoscape.model.CyNetwork)1 CyNode (org.cytoscape.model.CyNode)1 CyTable (org.cytoscape.model.CyTable)1 NetworkTestSupport (org.cytoscape.model.NetworkTestSupport)1