本文整理汇总了Java中org.gephi.data.attributes.api.AttributeController类的典型用法代码示例。如果您正苦于以下问题:Java AttributeController类的具体用法?Java AttributeController怎么用?Java AttributeController使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AttributeController类属于org.gephi.data.attributes.api包,在下文中一共展示了AttributeController类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: calculateClusteringCoefficient
import org.gephi.data.attributes.api.AttributeController; //导入依赖的package包/类
public GephiProcessing calculateClusteringCoefficient() {
Stopwatch stopwatch = Stopwatch.createStarted();
AttributeModel am = Lookup.getDefault().lookup(AttributeController.class).getModel();
ClusteringCoefficient clusteringCoefficient = new ClusteringCoefficient();
DynamicModel dynamicModel = Lookup.getDefault().lookup(DynamicController.class).getModel();
Log.info(LogCategory.GEXF, "Calculating average clustering coefficient...");
for (double i = 0.0; i < reportingIntervalCount; i++) {
double high = i + 0.9;
DynamicGraph dynamicGraph = dynamicModel.createDynamicGraph(graphModel.getGraph());
Graph subGraph = dynamicGraph.getSnapshotGraph(i, high);
clusteringCoefficient.execute(graphModel, am);
double sum = 0.0;
for (Node node : subGraph.getNodes()) {
sum += (double) node.getAttributes().getValue(ClusteringCoefficient.CLUSTERING_COEFF);
}
Double avg = sum / subGraph.getNodeCount();
clusteringCoefficientAverages.add(avg);
}
long timeElapsed = stopwatch.elapsed(TimeUnit.SECONDS);
Log.info(LogCategory.GEXF, "...Finished! (elapsed time: " + timeElapsed + "s");
return this;
}
示例2: calculateUndirectedDegree
import org.gephi.data.attributes.api.AttributeController; //导入依赖的package包/类
public GephiProcessing calculateUndirectedDegree() {
Stopwatch stopwatch = Stopwatch.createStarted();
AttributeModel am = Lookup.getDefault().lookup(AttributeController.class).getModel();
Degree degree = new Degree();
DynamicModel dynamicModel = Lookup.getDefault().lookup(DynamicController.class).getModel();
Log.info(LogCategory.GEXF, "Calculating averages for degree...");
for (double i = 0.0; i < reportingIntervalCount; i++) {
double high = i + 0.9;
DynamicGraph dynamicGraph = dynamicModel.createDynamicGraph(graphModel.getGraph());
Graph subGraph = dynamicGraph.getSnapshotGraph(i, high);
degree.execute(graphModel, am);
int degreeSum = 0;
for (Node node : subGraph.getNodes()) {
degreeSum += (int) node.getAttributes().getValue(Degree.DEGREE);
}
Double avgDegree = (double) degreeSum / subGraph.getNodeCount();
degreeAverages.add(avgDegree);
}
long timeElapsed = stopwatch.elapsed(TimeUnit.SECONDS);
Log.info(LogCategory.GEXF, ".. Finised (elapsed time: " + timeElapsed + "s");
return this;
}
示例3: calculateInDegree
import org.gephi.data.attributes.api.AttributeController; //导入依赖的package包/类
public GephiProcessing calculateInDegree() {
Stopwatch stopwatch = Stopwatch.createStarted();
AttributeModel am = Lookup.getDefault().lookup(AttributeController.class).getModel();
Degree degree = new Degree();
DynamicModel dynamicModel = Lookup.getDefault().lookup(DynamicController.class).getModel();
Log.info(LogCategory.GEXF, "Calculating averages for In-Degree...");
for (double i = 0.0; i < reportingIntervalCount; i++) {
double high = i + 0.9;
DynamicGraph dynamicGraph = dynamicModel.createDynamicGraph(graphModel.getGraph());
Graph subGraph = dynamicGraph.getSnapshotGraph(i, high);
degree.execute(graphModel, am);
int inDegreeSum = 0;
for (Node node : subGraph.getNodes()) {
inDegreeSum += (int) node.getAttributes().getValue(Degree.INDEGREE);
}
Double avgInDegree = (double) inDegreeSum / subGraph.getNodeCount();
inDegreeAverages.add(avgInDegree);
}
long timeElapsed = stopwatch.elapsed(TimeUnit.SECONDS);
Log.info(LogCategory.GEXF, ".. Finised (elapsed time: " + timeElapsed + "s");
return this;
}
示例4: calculateOutDegree
import org.gephi.data.attributes.api.AttributeController; //导入依赖的package包/类
public GephiProcessing calculateOutDegree() {
Stopwatch stopwatch = Stopwatch.createStarted();
AttributeModel am = Lookup.getDefault().lookup(AttributeController.class).getModel();
Degree degree = new Degree();
DynamicModel dynamicModel = Lookup.getDefault().lookup(DynamicController.class).getModel();
Log.info(LogCategory.GEXF, "Calculating averages for Out-degree...");
for (double i = 0.0; i < reportingIntervalCount; i++) {
double high = i + 0.9;
DynamicGraph dynamicGraph = dynamicModel.createDynamicGraph(graphModel.getGraph());
Graph subGraph = dynamicGraph.getSnapshotGraph(i, high);
degree.execute(graphModel, am);
int outDegreeSum = 0;
for (Node node : subGraph.getNodes()) {
outDegreeSum += (int) node.getAttributes().getValue(Degree.OUTDEGREE);
}
Double avgOutDegree = (double) outDegreeSum / subGraph.getNodeCount();
outDegreeAverages.add(avgOutDegree);
}
long timeElapsed = stopwatch.elapsed(TimeUnit.SECONDS);
Log.info(LogCategory.GEXF, ".. Finised (elapsed time: " + timeElapsed + "s");
return this;
}
示例5: finishedClicked
import org.gephi.data.attributes.api.AttributeController; //导入依赖的package包/类
/**
* This method handles the action, when "finish" is clicked
*/
public void finishedClicked() {
// check if really wants to finish
int result = JOptionPane.showConfirmDialog(mainFrame, "Do you really want to finish?", "Finishing...", JOptionPane.YES_NO_OPTION);
if(result != JOptionPane.YES_OPTION) {
return;
}
// add columns if not already existing
AttributeModel attrModel = Lookup.getDefault().lookup(AttributeController.class).getModel();
for(int i = 0; i < Constants.newColumnsNode.length; i++) {
if(attrModel.getNodeTable().getColumn(Constants.newColumnsNode[i]) == null) {
attrModel.getNodeTable().addColumn(Constants.newColumnsNode[i], Constants.newColumnsNodeType[i]);
}
}
for(int i = 0; i < Constants.newColumnsEdge.length; i++) {
if(attrModel.getEdgeTable().getColumn(Constants.newColumnsEdge[i]) == null) {
attrModel.getEdgeTable().addColumn(Constants.newColumnsEdge[i], Constants.newColumnsEdgeType[i]);
}
}
// close frame
mainFrame.dispose();
System.exit(0);
}
示例6: partition
import org.gephi.data.attributes.api.AttributeController; //导入依赖的package包/类
public Partition<Node> partition(Graph<MultimodalItem, SameClassLink> itemsGraph) {
UndirectedGraph graph = getGraph(itemsGraph);
System.out.println("Nodes: " + graph.getNodeCount());
System.out.println("Edges: " + graph.getEdgeCount());
AttributeModel attributeModel = Lookup.getDefault().lookup(AttributeController.class).getModel();
// Run modularity algorithm - community detection
Modularity modularity = new Modularity();
modularity.setUseWeight(true);
modularity.setResolution(1.);
modularity.setRandom(true);
modularity.execute(graphModel, attributeModel);
AttributeColumn modColumn = attributeModel.getNodeTable().getColumn(Modularity.MODULARITY_CLASS);
@SuppressWarnings("unchecked")
Partition<Node> p = partitionController.buildPartition(modColumn, graph);
return p;
}
示例7: addAttribute
import org.gephi.data.attributes.api.AttributeController; //导入依赖的package包/类
public static void addAttribute(String name, AttributeType type,
Object defaultValue) {
Lookup.getDefault()
.lookup(AttributeController.class)
.getModel()
.getNodeTable()
.addColumn(name, name, type, AttributeOrigin.PROPERTY,
defaultValue);
}
示例8: getEdgeFilter
import org.gephi.data.attributes.api.AttributeController; //导入依赖的package包/类
/**
* Creates a filter for the edges that belong to the MST. This filter is
* used to query a view of the graph containing only these edges (a view
* equivalent to the computed MST).
*
* @return The AbstractAttributeFilter edge filter created.
*/
protected AbstractAttributeFilter getEdgeFilter() {
EqualNumberFilter edgeFilter = new EqualNumberFilter(Lookup
.getDefault().lookup(AttributeController.class).getModel()
.getEdgeTable().getColumn(EDGE_ATTR_MST));
edgeFilter.setMatch(new Long(MST_ID));
return edgeFilter;
}
示例9: addAttribute
import org.gephi.data.attributes.api.AttributeController; //导入依赖的package包/类
public static void addAttribute(String name, AttributeType type,
Object defaultValue) {
Lookup.getDefault()
.lookup(AttributeController.class)
.getModel()
.getEdgeTable()
.addColumn(name, name, type, AttributeOrigin.PROPERTY,
defaultValue);
}
示例10: calculateDynamicCentralities
import org.gephi.data.attributes.api.AttributeController; //导入依赖的package包/类
public GephiProcessing calculateDynamicCentralities() {
Stopwatch stopwatch = Stopwatch.createStarted();
AttributeModel am = Lookup.getDefault().lookup(AttributeController.class).getModel();
GraphDistance graphDistance = new GraphDistance();
DynamicModel dynamicModel = Lookup.getDefault().lookup(DynamicController.class).getModel();
Log.info(LogCategory.GEXF, "Calculating average centralities...");
for (double i = 0.0; i < reportingIntervalCount; i++) {
double high = i + 1;
DynamicGraph dynamicGraph = dynamicModel.createDynamicGraph(graphModel.getGraph());
Graph subGraph = dynamicGraph.getSnapshotGraph(i, high);
graphDistance.execute(graphModel, am);
double betweennessSum = 0.0;
double closenessSum = 0.0;
double eccentricitySum = 0.0;
for (Node node : subGraph.getNodes()) {
betweennessSum += (double) node.getAttributes().getValue(GraphDistance.BETWEENNESS);
closenessSum += (double) node.getAttributes().getValue(GraphDistance.CLOSENESS);
eccentricitySum += (double) node.getAttributes().getValue(GraphDistance.ECCENTRICITY);
}
Double averageBetweenness = betweennessSum / subGraph.getNodeCount();
Double averageCloseness = closenessSum / subGraph.getNodeCount();
Double averageEccentricity = eccentricitySum / subGraph.getNodeCount();
betweennessAverages.add(averageBetweenness);
closenessAverages.add(averageCloseness);
eccentricityAverages.add(averageEccentricity);
}
long timeElapsed = stopwatch.elapsed(TimeUnit.SECONDS);
Log.info(LogCategory.GEXF, "...Finished! (elapsed time: " + timeElapsed + "s");
return this;
}
示例11: resetPropertiesValues
import org.gephi.data.attributes.api.AttributeController; //导入依赖的package包/类
@Override
public void resetPropertiesValues() {
AttributeModel attModel = Lookup.getDefault().lookup(AttributeController.class).getModel();
for (AttributeColumn c : attModel.getNodeTable().getColumns()) {
if(c.getId().equalsIgnoreCase("order")
|| c.getId().equalsIgnoreCase("ord")
|| c.getTitle().equalsIgnoreCase("order")
|| c.getTitle().equalsIgnoreCase("ord")) {
order = c;
} else {
order = null;
}
}
int nodesCount = 0;
if (graphModel != null) {
nodesCount = graphModel.getGraphVisible().getNodeCount();
}
setOrderScale(10.0);
// Tuning
setScalingRatio(1.0);
setStrongGravityMode(false);
setGravity(1.);
setVertical(false);
setCenter(false);
// Performance
if (nodesCount >= 50000) {
setJitterTolerance(10d);
} else if (nodesCount >= 5000) {
setJitterTolerance(1d);
} else {
setJitterTolerance(0.3d);
}
setThreadsCount(2);
}
示例12: averageControlMsgs
import org.gephi.data.attributes.api.AttributeController; //导入依赖的package包/类
/**
* Calculates the average number of control messages sent and received.
*
* The averages are calculated by dividing the total number of control messages sent/received
* over the entire execution of the protocol with the number of reporting intervals, i.e. it calculates
* control messages per reporting interval.
*
* @return A pointer to itself for easy client method chaining
*/
public GephiProcessing averageControlMsgs() {
AttributeModel am = Lookup.getDefault().lookup(AttributeController.class).getModel();
am.getNodeTable().addColumn(NodeAttributes.CONTROL_MSGS_SENT_AVG, AttributeType.DOUBLE);
am.getNodeTable().addColumn(NodeAttributes.CONTROL_MSGS_RECEIVED_AVG, AttributeType.DOUBLE);
for (double i = 0.0; i < reportingIntervalCount; i++) {
double high = i + 0.9;
Integer controlMsgSentCountTotal = 0;
Integer controlMsgRcvdCountTotal = 0;
for (Node node : graphModel.getGraph().getNodes()) {
DynamicInteger gossipsSent = (DynamicInteger) node.getAttributes().getValue(NodeAttributes.CONTROL_MSGS_SENT);
DynamicInteger gossipsReceived = (DynamicInteger) node.getAttributes().getValue(NodeAttributes.CONTROL_MSGS_RECEIVED);
if (gossipsSent == null || gossipsReceived == null) {
Log.debug(LogCategory.COLLECTOR, "Could not find control msg count attributes");
return this;
}
Integer controlMsgSentCount = gossipsSent.getValue(new Interval(i, high));
Integer controlMsgRcvdCount = gossipsReceived.getValue(new Interval(i, high));
// null value means the node was down for this interval due to churn
if (controlMsgRcvdCount != null && controlMsgSentCount != null) {
controlMsgSentCountTotal += controlMsgSentCount;
controlMsgRcvdCountTotal += controlMsgRcvdCount;
}
// double maxInterval = gossipsSent.getHigh();
// Integer gossipSentCount = gossipsSent.getValue(maxInterval - 1, maxInterval);
// Integer gossipReceivedCount = gossipsReceived.getValue(maxInterval - 1, maxInterval);
// Log.debug("node id: " + node.getNodeData().getId());
// Log.debug("gossipSentCount: " + gossipSentCount);
// Log.debug("reportingIntervalCount :" + reportingIntervalCount);
// Log.debug("average: " + gossipSentCount / reportingIntervalCount);
// node.getAttributes().setValue(NodeAttributes.CONTROL_MSGS_SENT_AVG, Math.round(avgGossipsSent * 100.0) / 100.0);
// node.getAttributes().setValue(NodeAttributes.CONTROL_MSGS_RECEIVED_AVG, Math.round(avgGossipsReceieved * 100.0) / 100.0);
}
double avgGossipsSent = (double) controlMsgSentCountTotal / graphModel.getGraph().getNodeCount();
double avgGossipsReceieved = (double) controlMsgRcvdCountTotal / graphModel.getGraph().getNodeCount();
controlMsgsSentAvg.add(avgGossipsSent);
controlMsgsRcvdAvg.add(avgGossipsReceieved);
}
return this;
}
示例13: averageTopicDiameter
import org.gephi.data.attributes.api.AttributeController; //导入依赖的package包/类
public GephiProcessing averageTopicDiameter(Set<String> topics) {
Stopwatch stopwatch = Stopwatch.createStarted();
final AttributeModel am = Lookup.getDefault().lookup(AttributeController.class).getModel();
final FilterController filterController = Lookup.getDefault().lookup(FilterController.class);
final DynamicModel dynamicModel = Lookup.getDefault().lookup(DynamicController.class).getModel();
DynamicGraph dynamicGraph = dynamicModel.createDynamicGraph(graphModel.getGraph());
final int topicSize = topics.size();
for (double i = 0.0; i < reportingIntervalCount; i++) {
Log.info(LogCategory.GEXF, "Calculating topic diameter for interval " + i + "...");
double diameter = 0;
double high = i + 1;
Graph graph = dynamicGraph.getSnapshotGraph(i, high);
// Log.debug(LogCategory.GEXF, "Node count: " + graph.getNodeCount());
// Log.debug(LogCategory.GEXF, "Edge count: " + graph.getEdgeCount());
for (String topic : topics) {
AttributeEqualBuilder.EqualStringFilter nodeFilter =
new AttributeEqualBuilder
.EqualStringFilter(am.getNodeTable().getColumn(NodeAttributes.TOPICS));
AttributeEqualBuilder.EqualStringFilter edgeFilter =
new AttributeEqualBuilder
.EqualStringFilter(am.getNodeTable().getColumn(EdgeAttributes.TOPICS));
final String pattern = ".*" + topic + ".*";
nodeFilter.init(graph);
edgeFilter.init(graph);
nodeFilter.setUseRegex(true);
edgeFilter.setUseRegex(true);
nodeFilter.setPattern(pattern);
edgeFilter.setPattern(pattern);
nodeFilter.evaluate(graph, graph);
nodeFilter.finish();
edgeFilter.evaluate(graph, graph);
edgeFilter.finish();
Query nodeQuery = filterController.createQuery(nodeFilter);
Query edgeQuery = filterController.createQuery(edgeFilter);
filterController.setSubQuery(nodeQuery, edgeQuery);
GraphView view = filterController.filter(edgeQuery);
graphModel.setVisibleView(view);
HierarchicalGraph subGraph = graphModel.getHierarchicalGraphVisible();
// Log.debug(LogCategory.GEXF, "Topic graph " + topic + " node count: " + subGraph.getNodeCount());
// Log.debug(LogCategory.GEXF, "Topic graph " + topic + " edge count: " + subGraph.getEdgeCount());
GraphDistance graphDistance = new GraphDistance();
graphDistance.execute(subGraph, am);
diameter += graphDistance.getDiameter();
}
double averageDiameter = diameter / topicSize;
// averageDiameter = (averageDiameter * 100.0) / 100.0;
topicDiameterAverages.add(averageDiameter);
}
long timeElapsed = stopwatch.elapsed(TimeUnit.SECONDS);
Log.info(LogCategory.GEXF, "...Finished! (elapsed time: " + timeElapsed + "s");
return this;
}
示例14: execute
import org.gephi.data.attributes.api.AttributeController; //导入依赖的package包/类
public boolean execute() {
try {
PreviewModel previewModel;
final PreviewController previewController = Lookup.getDefault().lookup(PreviewController.class);
//there seems to be a bug in gephi or in gephi & eclipse that needs a refresh of the preview - else the model is empty
previewController.refreshPreview();
previewModel = previewController.getModel();
AttributeModel model = Lookup.getDefault().lookup(AttributeController.class).getModel();
AttributeColumn[] nodeColums = model.getNodeTable().getColumns();
//try to find the GeoFields
AttributeColumn[] geoFields;
GeoAttributeFinder gaf = new GeoAttributeFinder();
geoFields = gaf.findGeoFields(nodeColums);
SHPExporterDialog exporterDialog;
exporterDialog = new SHPExporterDialog(nodeColums, geoFields);
exporterDialog.setTitle("SHP Export Options");
if (exporterDialog.showDialog()) {
geoFields = exporterDialog.getGeoFields();
File exportFile = exporterDialog.getFile();
//Construct Export Filenames
String baseName = exportFile.getName();
baseName = baseName.substring(0, baseName.lastIndexOf("."));
File pointFile = new File(exportFile.getParentFile(), baseName + ".node.shp");
File edgeFile = new File(exportFile.getParentFile(), baseName + ".edge.shp");
//convert data to pointFeatureSource
SimpleFeatureType pointFeatureType = getFeatureTypeForAttributes(Point.class, nodeColums);
SimpleFeatureCollection pointFeatureSource;
pointFeatureSource = getPointFeatureSource(previewModel, pointFeatureType, geoFields);
//convert data to edgeFeatureSource
AttributeColumn[] edgeColums = model.getEdgeTable().getColumns();
SimpleFeatureType edgeFeatureType = getFeatureTypeForAttributes(LineString.class, edgeColums);
SimpleFeatureCollection edgeFeatureSource;
edgeFeatureSource = getFeatureSource(false, previewModel, edgeFeatureType, geoFields);
//Create Shapefile
//Netbean securit-manager ist running wild - dunno what to do but cathc the exception
writeSHP(pointFile.toURL(), pointFeatureType, pointFeatureSource);
writeSHP(edgeFile.toURL(), edgeFeatureType, edgeFeatureSource);
return true;
}
} catch (IOException ex) {
Logger.getLogger(SHPExporter.class.getName()).log(Level.SEVERE, null, ex);
}
return true;
}