Search in sources :

Example 1 with TimeRepresentation

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());
        }
    }
}
Also used : ColumnDraft(org.gephi.io.importer.api.ColumnDraft) Table(org.gephi.graph.api.Table) TimeRepresentation(org.gephi.graph.api.TimeRepresentation)

Example 2 with TimeRepresentation

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);
}
Also used : Graph(org.gephi.graph.api.Graph) TimeRepresentation(org.gephi.graph.api.TimeRepresentation) Node(org.gephi.graph.api.Node) ClusteringCoefficient(org.gephi.statistics.plugin.ClusteringCoefficient) Interval(org.gephi.graph.api.Interval)

Example 3 with TimeRepresentation

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);
        }
    }
}
Also used : Table(org.gephi.graph.api.Table) TimeRepresentation(org.gephi.graph.api.TimeRepresentation)

Example 4 with TimeRepresentation

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());
}
Also used : DirectedGraph(org.gephi.graph.api.DirectedGraph) Graph(org.gephi.graph.api.Graph) DirectedGraph(org.gephi.graph.api.DirectedGraph) TimeRepresentation(org.gephi.graph.api.TimeRepresentation) Node(org.gephi.graph.api.Node) Interval(org.gephi.graph.api.Interval)

Example 5 with TimeRepresentation

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);
        }
    }
}
Also used : Table(org.gephi.graph.api.Table) TimeRepresentation(org.gephi.graph.api.TimeRepresentation)

Aggregations

TimeRepresentation (org.gephi.graph.api.TimeRepresentation)7 Interval (org.gephi.graph.api.Interval)3 Table (org.gephi.graph.api.Table)3 Graph (org.gephi.graph.api.Graph)2 Node (org.gephi.graph.api.Node)2 ArrayList (java.util.ArrayList)1 Set (java.util.Set)1 Column (org.gephi.graph.api.Column)1 DirectedGraph (org.gephi.graph.api.DirectedGraph)1 Element (org.gephi.graph.api.Element)1 GraphController (org.gephi.graph.api.GraphController)1 IntervalSet (org.gephi.graph.api.types.IntervalSet)1 TimestampSet (org.gephi.graph.api.types.TimestampSet)1 ColumnDraft (org.gephi.io.importer.api.ColumnDraft)1 ClusteringCoefficient (org.gephi.statistics.plugin.ClusteringCoefficient)1