Search in sources :

Example 1 with Config

use of au.gov.asd.tac.constellation.plugins.algorithms.clustering.infomap.io.Config in project constellation by constellation-app.

the class InfoMapPanel method getConfig.

public Config getConfig() {
    final Config config = new Config();
    // Connection type.
    if (rbTransactions.isSelected()) {
        config.setConnectionType(Config.ConnectionType.TRANSACTIONS);
    } else if (rbEdges.isSelected()) {
        config.setConnectionType(Config.ConnectionType.EDGES);
    } else if (rbLinks.isSelected()) {
        config.setConnectionType(Config.ConnectionType.LINKS);
    } else {
    // Do nothing
    }
    // Dynamic type.
    if (rbDirected.isSelected()) {
        config.setDirected(true);
    } else if (rbUndirdir.isSelected()) {
        config.setUndirdir(true);
    } else if (rbOutdirdir.isSelected()) {
        config.setOutdirdir(true);
    } else if (rbRawdir.isSelected()) {
        config.setRawdir(true);
    } else {
    // Do nothing
    }
    config.setOptimizationLevel(cbOptLevel.getSelectedIndex());
    config.setFastHierarchicalSolution(cbHierarchical.getSelectedIndex());
    config.setNumTrials(((SpinnerNumberModel) sNumTrials.getModel()).getNumber().intValue());
    return config;
}
Also used : SpinnerNumberModel(javax.swing.SpinnerNumberModel) Config(au.gov.asd.tac.constellation.plugins.algorithms.clustering.infomap.io.Config)

Example 2 with Config

use of au.gov.asd.tac.constellation.plugins.algorithms.clustering.infomap.io.Config in project constellation by constellation-app.

the class InfoMapPlugin method edit.

@Override
protected void edit(final GraphWriteMethods wg, final PluginInteraction interaction, final PluginParameters parameters) throws InterruptedException, PluginException {
    if (wg.getVertexCount() <= 0) {
        interaction.notify(PluginNotificationLevel.ERROR, "The graph must have at least one vertex to run clustering on");
        LOGGER.log(Level.WARNING, "{0} run on Empty Graph", Bundle.InfoMapPlugin());
        return;
    }
    final Config config = (Config) parameters.getParameters().get(CONFIG_PARAMETER_ID).getObjectValue();
    final InfoMapContext context = new InfoMapContext(config, wg);
    context.getInfoMap().run();
    final int clusterAttrId = ClusteringConcept.VertexAttribute.INFOMAP_CLUSTER.ensure(wg);
    final InfomapBase infomap = context.getInfoMap();
    final TreeData treeData = infomap.getTreeData();
    LOGGER.log(Level.INFO, "Vertices {0}", treeData.getNumLeafNodes());
    for (final NodeBase node : treeData.getLeaves()) {
        final int index = node.getParent().getIndex();
        wg.setIntValue(clusterAttrId, wg.getVertex(node.getOriginalIndex()), index + 1);
    }
}
Also used : Config(au.gov.asd.tac.constellation.plugins.algorithms.clustering.infomap.io.Config) TreeData(au.gov.asd.tac.constellation.plugins.algorithms.clustering.infomap.tree.TreeData) InfomapBase(au.gov.asd.tac.constellation.plugins.algorithms.clustering.infomap.infomap.InfomapBase)

Example 3 with Config

use of au.gov.asd.tac.constellation.plugins.algorithms.clustering.infomap.io.Config in project constellation by constellation-app.

the class InfoMapPlugin method createParameters.

@Override
public PluginParameters createParameters() {
    final PluginParameters parameters = new PluginParameters();
    final PluginParameter<ObjectParameterValue> configParam = ObjectParameterType.build(CONFIG_PARAMETER_ID);
    configParam.setName("Config");
    configParam.setDescription("A Config object which defines the Info Map");
    configParam.setObjectValue(new Config());
    parameters.addParameter(configParam);
    return parameters;
}
Also used : Config(au.gov.asd.tac.constellation.plugins.algorithms.clustering.infomap.io.Config) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) ObjectParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.ObjectParameterType.ObjectParameterValue)

Example 4 with Config

use of au.gov.asd.tac.constellation.plugins.algorithms.clustering.infomap.io.Config in project constellation by constellation-app.

the class InfoMapMainNGTest method testMain.

/**
 * Test of InfoMapMain.
 *
 * @throws java.lang.Exception
 */
@Test
public void testMain() throws Exception {
    final String fnam = "ninetriangles" + GraphDataObject.FILE_EXTENSION;
    // A test graph.
    Graph graph;
    try (InputStream inStream = InfoMapMainNGTest.class.getResourceAsStream(fnam)) {
        graph = new GraphJsonReader().readGraphZip(fnam, inStream, new TextIoProgress(true));
    }
    final Config conf = new Config();
    conf.setNoFileOutput(false);
    conf.setVerbosity(1);
    conf.setNetworkFile(fnam);
    conf.setOutDirectory(System.getProperty("java.io.tmpdir"));
    conf.setPrintClu(true);
    conf.setPrintNodeRanks(true);
    conf.setPrintFlowNetwork(true);
    conf.setVerbosity(1);
    conf.setNumTrials(5);
    System.out.printf("fastHierarchicalSolution %d\n", conf.getFastHierarchicalSolution());
    System.out.printf("Parsing %s network from file '%s'... ", conf.isUndirected() ? "undirected" : "directed", conf.getNetworkFile());
    conf.setConnectionType(Config.ConnectionType.TRANSACTIONS);
    final ReadableGraph rg = graph.getReadableGraph();
    try {
        System.out.printf("vertices=%d, Transactions=%d edges=%d links=%d\n", rg.getVertexCount(), rg.getTransactionCount(), rg.getEdgeCount(), rg.getLinkCount());
        runInfoMap(conf, rg);
    } finally {
        rg.release();
    }
}
Also used : ReadableGraph(au.gov.asd.tac.constellation.graph.ReadableGraph) ReadableGraph(au.gov.asd.tac.constellation.graph.ReadableGraph) Graph(au.gov.asd.tac.constellation.graph.Graph) InputStream(java.io.InputStream) Config(au.gov.asd.tac.constellation.plugins.algorithms.clustering.infomap.io.Config) TextIoProgress(au.gov.asd.tac.constellation.utilities.gui.TextIoProgress) GraphJsonReader(au.gov.asd.tac.constellation.graph.file.io.GraphJsonReader) Test(org.testng.annotations.Test)

Aggregations

Config (au.gov.asd.tac.constellation.plugins.algorithms.clustering.infomap.io.Config)4 Graph (au.gov.asd.tac.constellation.graph.Graph)1 ReadableGraph (au.gov.asd.tac.constellation.graph.ReadableGraph)1 GraphJsonReader (au.gov.asd.tac.constellation.graph.file.io.GraphJsonReader)1 InfomapBase (au.gov.asd.tac.constellation.plugins.algorithms.clustering.infomap.infomap.InfomapBase)1 TreeData (au.gov.asd.tac.constellation.plugins.algorithms.clustering.infomap.tree.TreeData)1 PluginParameters (au.gov.asd.tac.constellation.plugins.parameters.PluginParameters)1 ObjectParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.ObjectParameterType.ObjectParameterValue)1 TextIoProgress (au.gov.asd.tac.constellation.utilities.gui.TextIoProgress)1 InputStream (java.io.InputStream)1 SpinnerNumberModel (javax.swing.SpinnerNumberModel)1 Test (org.testng.annotations.Test)1