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;
}
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);
}
}
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;
}
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();
}
}
Aggregations