Search in sources :

Example 1 with GraphModel

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

the class StatisticsControllerImpl method executeDynamic.

private void executeDynamic(DynamicStatistics statistics, DynamicLongTask dynamicLongTask) {
    GraphController graphController = Lookup.getDefault().lookup(GraphController.class);
    GraphModel graphModel = graphController.getGraphModel();
    double window = statistics.getWindow();
    double tick = statistics.getTick();
    GraphView currentView = graphModel.getVisibleView();
    Interval bounds = statistics.getBounds();
    if (bounds == null) {
        if (currentView.isMainView()) {
            bounds = graphModel.getTimeBounds();
        } else {
            bounds = currentView.getTimeInterval();
        }
        statistics.setBounds(bounds);
    }
    if (dynamicLongTask != null) {
        //Count
        int c = (int) ((bounds.getHigh() - window - bounds.getLow()) / tick);
        dynamicLongTask.start(c);
    }
    //Init
    statistics.execute(graphModel);
    //Loop
    for (double low = bounds.getLow(); low <= bounds.getHigh() - window; low += tick) {
        double high = low + window;
        Graph graph = graphModel.getGraphVisible();
        graph.writeLock();
        try {
            GraphView view = graphModel.createView();
            Subgraph g = graphModel.getGraph(view);
            TimeIndex<Node> nodeIndex = graphModel.getNodeTimeIndex(currentView);
            if (Double.isInfinite(nodeIndex.getMinTimestamp()) && Double.isInfinite(nodeIndex.getMaxTimestamp())) {
                for (Node node : graph.getNodes()) {
                    g.addNode(node);
                }
            } else {
                for (Node node : nodeIndex.get(new Interval(low, high))) {
                    g.addNode(node);
                }
            }
            TimeIndex<Edge> edgeIndex = graphModel.getEdgeTimeIndex(currentView);
            if (Double.isInfinite(edgeIndex.getMinTimestamp()) && Double.isInfinite(edgeIndex.getMaxTimestamp())) {
                for (Edge edge : graph.getEdges()) {
                    if (g.contains(edge.getSource()) && g.contains(edge.getTarget())) {
                        g.addEdge(edge);
                    }
                }
            } else {
                for (Edge edge : edgeIndex.get(new Interval(low, high))) {
                    if (g.contains(edge.getSource()) && g.contains(edge.getTarget())) {
                        g.addEdge(edge);
                    }
                }
            }
            statistics.loop(g.getView(), new Interval(low, high));
        } finally {
            graph.writeUnlock();
        }
        //Cancelled?
        if (dynamicLongTask != null && dynamicLongTask.isCancelled()) {
            return;
        } else if (dynamicLongTask != null) {
            dynamicLongTask.progress();
        }
    }
    statistics.end();
    model.addReport(statistics);
}
Also used : Graph(org.gephi.graph.api.Graph) GraphModel(org.gephi.graph.api.GraphModel) Node(org.gephi.graph.api.Node) Subgraph(org.gephi.graph.api.Subgraph) GraphView(org.gephi.graph.api.GraphView) Edge(org.gephi.graph.api.Edge) GraphController(org.gephi.graph.api.GraphController) Interval(org.gephi.graph.api.Interval)

Example 2 with GraphModel

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

the class StatisticsControllerImpl method execute.

@Override
public void execute(Statistics statistics) {
    if (statistics instanceof DynamicStatistics) {
        executeDynamic((DynamicStatistics) statistics, null);
    } else {
        GraphController graphController = Lookup.getDefault().lookup(GraphController.class);
        GraphModel graphModel = graphController.getGraphModel();
        statistics.execute(graphModel);
        model.addReport(statistics);
    }
}
Also used : GraphModel(org.gephi.graph.api.GraphModel) DynamicStatistics(org.gephi.statistics.spi.DynamicStatistics) GraphController(org.gephi.graph.api.GraphController)

Example 3 with GraphModel

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

the class MergeColumnsUI method loadColumns.

private void loadColumns() {
    availableColumnsModel.clear();
    columnsToMergeModel.clear();
    GraphModel am = Lookup.getDefault().lookup(GraphController.class).getGraphModel();
    Column[] columns;
    if (mode == Mode.NODES_TABLE) {
        table = am.getNodeTable();
        columns = table.toArray();
    } else {
        table = am.getEdgeTable();
        columns = table.toArray();
    }
    for (Column column : columns) {
        availableColumnsModel.addElement(new ColumnWrapper(column));
    }
    availableColumnsList.setModel(availableColumnsModel);
    columnsToMergeList.setModel(columnsToMergeModel);
}
Also used : Column(org.gephi.graph.api.Column) GraphModel(org.gephi.graph.api.GraphModel) GraphController(org.gephi.graph.api.GraphController)

Example 4 with GraphModel

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

the class InterEdgesBuilder method getBuilders.

@Override
public FilterBuilder[] getBuilders(Workspace workspace) {
    List<FilterBuilder> builders = new ArrayList<>();
    GraphModel gm = Lookup.getDefault().lookup(GraphController.class).getGraphModel(workspace);
    Graph graph = gm.getGraph();
    AppearanceModel am = Lookup.getDefault().lookup(AppearanceController.class).getModel(workspace);
    //Force refresh
    am.getNodeFunctions(graph);
    for (Column nodeCol : gm.getNodeTable()) {
        if (!nodeCol.isProperty()) {
            if (am.getNodePartition(graph, nodeCol) != null) {
                InterEdgesFilterBuilder builder = new InterEdgesFilterBuilder(nodeCol, am);
                builders.add(builder);
            }
        }
    }
    return builders.toArray(new FilterBuilder[0]);
}
Also used : Graph(org.gephi.graph.api.Graph) AppearanceModel(org.gephi.appearance.api.AppearanceModel) Column(org.gephi.graph.api.Column) FilterBuilder(org.gephi.filters.spi.FilterBuilder) GraphModel(org.gephi.graph.api.GraphModel) ArrayList(java.util.ArrayList) AppearanceController(org.gephi.appearance.api.AppearanceController) GraphController(org.gephi.graph.api.GraphController)

Example 5 with GraphModel

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

the class PartitionCountBuilder method getBuilders.

@Override
public FilterBuilder[] getBuilders(Workspace workspace) {
    List<FilterBuilder> builders = new ArrayList<>();
    GraphModel gm = Lookup.getDefault().lookup(GraphController.class).getGraphModel(workspace);
    Graph graph = gm.getGraph();
    AppearanceModel am = Lookup.getDefault().lookup(AppearanceController.class).getModel(workspace);
    //Force refresh
    am.getNodeFunctions(graph);
    for (Column nodeCol : gm.getNodeTable()) {
        if (!nodeCol.isProperty()) {
            if (am.getNodePartition(graph, nodeCol) != null) {
                PartitionCountFilterBuilder builder = new PartitionCountFilterBuilder(nodeCol, am);
                builders.add(builder);
            }
        }
    }
    for (Column edgeCol : gm.getEdgeTable()) {
        if (!edgeCol.isProperty()) {
            if (am.getEdgePartition(graph, edgeCol) != null) {
                PartitionCountFilterBuilder builder = new PartitionCountFilterBuilder(edgeCol, am);
                builders.add(builder);
            }
        }
    }
    return builders.toArray(new FilterBuilder[0]);
}
Also used : Graph(org.gephi.graph.api.Graph) AppearanceModel(org.gephi.appearance.api.AppearanceModel) Column(org.gephi.graph.api.Column) AbstractAttributeFilterBuilder(org.gephi.filters.plugin.AbstractAttributeFilterBuilder) GraphModel(org.gephi.graph.api.GraphModel) ArrayList(java.util.ArrayList) AppearanceController(org.gephi.appearance.api.AppearanceController) GraphController(org.gephi.graph.api.GraphController)

Aggregations

GraphModel (org.gephi.graph.api.GraphModel)235 Node (org.gephi.graph.api.Node)169 Test (org.testng.annotations.Test)168 UndirectedGraph (org.gephi.graph.api.UndirectedGraph)115 GraphController (org.gephi.graph.api.GraphController)105 DirectedGraph (org.gephi.graph.api.DirectedGraph)92 Edge (org.gephi.graph.api.Edge)80 Graph (org.gephi.graph.api.Graph)57 HashMap (java.util.HashMap)52 Column (org.gephi.graph.api.Column)16 LinkedList (java.util.LinkedList)12 ArrayList (java.util.ArrayList)11 FilterBuilder (org.gephi.filters.spi.FilterBuilder)6 GraphView (org.gephi.graph.api.GraphView)6 XMLStreamException (javax.xml.stream.XMLStreamException)5 IOException (java.io.IOException)4 AppearanceController (org.gephi.appearance.api.AppearanceController)4 AppearanceModel (org.gephi.appearance.api.AppearanceModel)4 TimeFormat (org.gephi.graph.api.TimeFormat)4 Element (org.gephi.graph.api.Element)3