Search in sources :

Example 6 with Interval

use of org.gephi.graph.api.Interval 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 7 with Interval

use of org.gephi.graph.api.Interval 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 8 with Interval

use of org.gephi.graph.api.Interval in project gephi by gephi.

the class AttributeColumnsControllerImpl method convertColumnToDynamic.

private Column convertColumnToDynamic(Table table, Column column, double low, double high, String newColumnTitle) {
    Class oldType = column.getTypeClass();
    TimeRepresentation timeRepresentation = Lookup.getDefault().lookup(GraphController.class).getGraphModel().getConfiguration().getTimeRepresentation();
    Class<?> newType;
    if (timeRepresentation == TimeRepresentation.TIMESTAMP) {
        newType = AttributeUtils.getTimestampMapType(oldType);
    } else {
        newType = AttributeUtils.getIntervalMapType(oldType);
    }
    if (newColumnTitle != null) {
        if (newColumnTitle.equals(column.getTitle())) {
            throw new IllegalArgumentException("Column titles can't be equal");
        }
    }
    Element[] rows = getTableAttributeRows(table);
    Object[] oldValues = new Object[rows.length];
    for (int i = 0; i < rows.length; i++) {
        oldValues[i] = rows[i].getAttribute(column);
    }
    Column newColumn;
    if (newColumnTitle == null) {
        table.removeColumn(column);
        newColumn = table.addColumn(column.getTitle(), newType, column.getOrigin());
    } else {
        newColumn = table.addColumn(newColumnTitle, newType, column.getOrigin());
    }
    if (timeRepresentation == TimeRepresentation.TIMESTAMP) {
        for (int i = 0; i < rows.length; i++) {
            if (oldValues[i] != null) {
                rows[i].setAttribute(newColumn, oldValues[i], low);
            }
        }
    } else {
        Interval interval = new Interval(low, high);
        for (int i = 0; i < rows.length; i++) {
            if (oldValues[i] != null) {
                rows[i].setAttribute(newColumn, oldValues[i], interval);
            }
        }
    }
    return newColumn;
}
Also used : Column(org.gephi.graph.api.Column) TimeRepresentation(org.gephi.graph.api.TimeRepresentation) Element(org.gephi.graph.api.Element) GraphController(org.gephi.graph.api.GraphController) Interval(org.gephi.graph.api.Interval)

Example 9 with Interval

use of org.gephi.graph.api.Interval in project gephi by gephi.

the class GraphObserverThread method run.

@Override
public void run() {
    while (!stop) {
        GraphModel graphModel = timelineModel.getGraphModel();
        Interval bounds = graphModel.getTimeBounds();
        if (!bounds.equals(interval)) {
            interval = bounds;
            timelineController.setMinMax(interval.getLow(), interval.getHigh());
        }
        try {
            Thread.sleep(1000);
        } catch (InterruptedException ex) {
        }
    }
}
Also used : GraphModel(org.gephi.graph.api.GraphModel) Interval(org.gephi.graph.api.Interval)

Example 10 with Interval

use of org.gephi.graph.api.Interval in project gephi by gephi.

the class AbstractElementsDataTable method refreshModel.

public void refreshModel(T[] elements, Column[] cols, GraphModel graphModel, DataTablesModel dataTablesModel) {
    this.graphModel = graphModel;
    showingColumns = cols;
    Interval timeBounds = graphModel.getTimeBounds();
    double min = timeBounds != null ? timeBounds.getLow() : 0;
    double max = timeBounds != null ? timeBounds.getHigh() : 0;
    refreshCellRenderersConfiguration(graphModel, min, max);
    refreshingTable = true;
    if (selectedElements == null) {
        selectedElements = getElementsFromSelectedRows();
    }
    ArrayList<ElementDataColumn<T>> columns = new ArrayList<>();
    columns.addAll(getFakeDataColumns(graphModel, dataTablesModel));
    for (Column c : cols) {
        columns.add(new AttributeDataColumn<T>(attributeColumnsController, c));
    }
    if (model == null) {
        model = new ElementsDataTableModel<>(elements, columns.toArray(new ElementDataColumn[0]));
        table.setModel(model);
    } else {
        model.configure(elements, columns.toArray(new ElementDataColumn[0]));
    }
    //Keep row selection before refreshing.
    setElementsSelection(selectedElements);
    selectedElements = null;
    refreshingTable = false;
}
Also used : AttributeDataColumn(org.gephi.desktop.datalab.tables.columns.AttributeDataColumn) ElementDataColumn(org.gephi.desktop.datalab.tables.columns.ElementDataColumn) Column(org.gephi.graph.api.Column) ArrayList(java.util.ArrayList) ElementDataColumn(org.gephi.desktop.datalab.tables.columns.ElementDataColumn) Interval(org.gephi.graph.api.Interval)

Aggregations

Interval (org.gephi.graph.api.Interval)12 ArrayList (java.util.ArrayList)3 Column (org.gephi.graph.api.Column)3 Graph (org.gephi.graph.api.Graph)3 Node (org.gephi.graph.api.Node)3 TimeRepresentation (org.gephi.graph.api.TimeRepresentation)3 Issue (org.gephi.io.importer.api.Issue)3 Element (org.gephi.graph.api.Element)2 GraphController (org.gephi.graph.api.GraphController)2 GraphModel (org.gephi.graph.api.GraphModel)2 IntervalMap (org.gephi.graph.api.types.IntervalMap)2 IntervalSet (org.gephi.graph.api.types.IntervalSet)2 AttributeColumnsController (org.gephi.datalab.api.AttributeColumnsController)1 AttributeDataColumn (org.gephi.desktop.datalab.tables.columns.AttributeDataColumn)1 ElementDataColumn (org.gephi.desktop.datalab.tables.columns.ElementDataColumn)1 DirectedGraph (org.gephi.graph.api.DirectedGraph)1 Edge (org.gephi.graph.api.Edge)1 GraphView (org.gephi.graph.api.GraphView)1 Subgraph (org.gephi.graph.api.Subgraph)1 ClusteringCoefficient (org.gephi.statistics.plugin.ClusteringCoefficient)1