use of org.gephi.graph.api.TimeRepresentation in project gephi by gephi.
the class AbstractProcessor method flushColumns.
protected void flushColumns(ContainerUnloader container) {
TimeRepresentation timeRepresentation = container.getTimeRepresentation();
Table nodeTable = graphModel.getNodeTable();
for (ColumnDraft col : container.getNodeColumns()) {
if (!nodeTable.hasColumn(col.getId())) {
Class typeClass = col.getTypeClass();
if (col.isDynamic()) {
if (timeRepresentation.equals(TimeRepresentation.TIMESTAMP)) {
typeClass = AttributeUtils.getTimestampMapType(typeClass);
} else {
typeClass = AttributeUtils.getIntervalMapType(typeClass);
}
}
nodeTable.addColumn(col.getId(), col.getTitle(), typeClass, Origin.DATA, col.getDefaultValue(), !col.isDynamic());
}
}
Table edgeTable = graphModel.getEdgeTable();
for (ColumnDraft col : container.getEdgeColumns()) {
if (!edgeTable.hasColumn(col.getId())) {
Class typeClass = col.getTypeClass();
if (col.isDynamic()) {
if (timeRepresentation.equals(TimeRepresentation.TIMESTAMP)) {
typeClass = AttributeUtils.getTimestampMapType(typeClass);
} else {
typeClass = AttributeUtils.getIntervalMapType(typeClass);
}
}
edgeTable.addColumn(col.getId(), col.getTitle(), typeClass, Origin.DATA, col.getDefaultValue(), !col.isDynamic());
}
}
}
use of org.gephi.graph.api.TimeRepresentation in project gephi by gephi.
the class DynamicClusteringCoefficient method loop.
@Override
public void loop(GraphView window, Interval interval) {
Graph graph;
if (isDirected) {
graph = graphModel.getDirectedGraph(window);
} else {
graph = graphModel.getUndirectedGraph(window);
}
TimeRepresentation tr = graphModel.getConfiguration().getTimeRepresentation();
graph.readLock();
try {
clusteringCoefficientStat = new ClusteringCoefficient();
clusteringCoefficientStat.setDirected(isDirected);
clusteringCoefficientStat.triangles(graph);
//Columns
if (!averageOnly) {
double[] coefficients = clusteringCoefficientStat.getCoefficientReuslts();
int i = 0;
for (Node n : graph.getNodes()) {
double coef = coefficients[i++];
switch(tr) {
case INTERVAL:
n.setAttribute(dynamicCoefficientColumn, coef, new Interval(interval.getLow(), interval.getLow() + tick));
break;
case TIMESTAMP:
n.setAttribute(dynamicCoefficientColumn, coef, interval.getLow());
n.setAttribute(dynamicCoefficientColumn, coef, interval.getHigh());
break;
}
if (cancel) {
break;
}
}
}
} finally {
graph.readUnlockAll();
}
//Average
double avg = clusteringCoefficientStat.getAverageClusteringCoefficient();
graphModel.getGraphVisible().setAttribute(DYNAMIC_AVG_CLUSTERING_COEFFICIENT, avg, interval.getLow());
graphModel.getGraphVisible().setAttribute(DYNAMIC_AVG_CLUSTERING_COEFFICIENT, avg, interval.getHigh());
averages.put(interval.getLow(), avg);
averages.put(interval.getHigh(), avg);
}
use of org.gephi.graph.api.TimeRepresentation in project gephi by gephi.
the class DynamicClusteringCoefficient method execute.
@Override
public void execute(GraphModel graphModel) {
this.graphModel = graphModel;
this.isDirected = graphModel.isDirected();
this.averages = new HashMap<>();
//Attributes cols
if (!averageOnly) {
TimeRepresentation tr = graphModel.getConfiguration().getTimeRepresentation();
Table nodeTable = graphModel.getNodeTable();
dynamicCoefficientColumn = nodeTable.getColumn(DYNAMIC_CLUSTERING_COEFFICIENT);
if (dynamicCoefficientColumn == null) {
dynamicCoefficientColumn = nodeTable.addColumn(DYNAMIC_CLUSTERING_COEFFICIENT, NbBundle.getMessage(DynamicClusteringCoefficient.class, "DynamicClusteringCoefficient.nodecolumn.ClusteringCoefficient"), tr.equals(TimeRepresentation.INTERVAL) ? IntervalDoubleMap.class : TimestampDoubleMap.class, null);
}
}
}
use of org.gephi.graph.api.TimeRepresentation in project gephi by gephi.
the class DynamicDegree method loop.
@Override
public void loop(GraphView window, Interval interval) {
Graph graph = graphModel.getGraph(window);
DirectedGraph directedGraph = null;
if (isDirected) {
directedGraph = graphModel.getDirectedGraph(window);
}
TimeRepresentation tr = graphModel.getConfiguration().getTimeRepresentation();
long sum = 0;
for (Node n : graph.getNodes().toArray()) {
int degree = graph.getDegree(n);
if (!averageOnly) {
switch(tr) {
case INTERVAL:
n.setAttribute(dynamicDegreeColumn, degree, new Interval(interval.getLow(), interval.getLow() + tick));
break;
case TIMESTAMP:
n.setAttribute(dynamicDegreeColumn, degree, interval.getLow());
n.setAttribute(dynamicDegreeColumn, degree, interval.getHigh());
break;
}
if (isDirected) {
int indegree = directedGraph.getInDegree(n);
int outdegree = directedGraph.getOutDegree(n);
switch(tr) {
case INTERVAL:
n.setAttribute(dynamicInDegreeColumn, indegree, new Interval(interval.getLow(), interval.getLow() + tick));
n.setAttribute(dynamicOutDegreeColumn, outdegree, new Interval(interval.getLow(), interval.getLow() + tick));
break;
case TIMESTAMP:
n.setAttribute(dynamicInDegreeColumn, indegree, interval.getLow());
n.setAttribute(dynamicInDegreeColumn, indegree, interval.getHigh());
n.setAttribute(dynamicOutDegreeColumn, outdegree, interval.getLow());
n.setAttribute(dynamicOutDegreeColumn, outdegree, interval.getHigh());
break;
}
}
}
sum += degree;
if (cancel) {
break;
}
}
double avg = sum / (double) graph.getNodeCount();
averages.put(interval.getLow(), avg);
averages.put(interval.getHigh(), avg);
graphModel.getGraphVisible().setAttribute(DYNAMIC_AVGDEGREE, avg, interval.getLow());
graphModel.getGraphVisible().setAttribute(DYNAMIC_AVGDEGREE, avg, interval.getHigh());
}
use of org.gephi.graph.api.TimeRepresentation in project gephi by gephi.
the class DynamicDegree method execute.
@Override
public void execute(GraphModel graphModel) {
this.graphModel = graphModel;
this.isDirected = graphModel.isDirected();
this.averages = new HashMap<>();
//Attributes cols
if (!averageOnly) {
TimeRepresentation tr = graphModel.getConfiguration().getTimeRepresentation();
Table nodeTable = graphModel.getNodeTable();
dynamicInDegreeColumn = nodeTable.getColumn(DYNAMIC_INDEGREE);
dynamicOutDegreeColumn = nodeTable.getColumn(DYNAMIC_OUTDEGREE);
dynamicDegreeColumn = nodeTable.getColumn(DYNAMIC_DEGREE);
if (isDirected) {
if (dynamicInDegreeColumn == null) {
dynamicInDegreeColumn = nodeTable.addColumn(DYNAMIC_INDEGREE, NbBundle.getMessage(DynamicDegree.class, "DynamicDegree.nodecolumn.InDegree"), tr.equals(TimeRepresentation.INTERVAL) ? IntervalIntegerMap.class : TimestampIntegerMap.class, null);
}
if (dynamicOutDegreeColumn == null) {
dynamicOutDegreeColumn = nodeTable.addColumn(DYNAMIC_OUTDEGREE, NbBundle.getMessage(DynamicDegree.class, "DynamicDegree.nodecolumn.OutDegree"), tr.equals(TimeRepresentation.INTERVAL) ? IntervalIntegerMap.class : TimestampIntegerMap.class, null);
}
}
if (dynamicDegreeColumn == null) {
dynamicDegreeColumn = nodeTable.addColumn(DYNAMIC_DEGREE, NbBundle.getMessage(DynamicDegree.class, "DynamicDegree.nodecolumn.Degree"), tr.equals(TimeRepresentation.INTERVAL) ? IntervalIntegerMap.class : TimestampIntegerMap.class, null);
}
}
}
Aggregations