Package org.gephi.graph.api

Examples of org.gephi.graph.api.Graph


                nodeDynamicColumns.add(col);
            }
        }
        AttributeColumn[] dynamicCols = nodeDynamicColumns.toArray(new AttributeColumn[0]);
        if (dynamicCols.length > 0) {
            Graph graph = graphModel.getGraph();
            for (Node n : graph.getNodes()) {
                Attributes attributeRow = n.getNodeData().getAttributes();
                for (int i = 0; i < dynamicCols.length; i++) {
                    DynamicType<?> ti = (DynamicType) attributeRow.getValue(dynamicCols[i].getIndex());
                    if (ti != null) {
                        for (Interval interval : ti.getIntervals(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY)) {
                            timeIntervalIndex.add(interval);
                        }
                    }
                }
            }
        }
        for (AttributeColumn col : attributeModel.getNodeTable().getColumns()) {
            if (col.getType().isDynamicType()) {
                edgeDynamicColumns.add(col);
            }
        }
        dynamicCols = nodeDynamicColumns.toArray(new AttributeColumn[0]);
        if (dynamicCols.length > 0) {
            Graph graph = graphModel.getGraph();
            for (Edge e : graph.getEdges()) {
                Attributes attributeRow = e.getEdgeData().getAttributes();
                for (int i = 0; i < dynamicCols.length; i++) {
                    DynamicType<?> ti = (DynamicType) attributeRow.getValue(dynamicCols[i].getIndex());
                    if (ti != null) {
                        for (Interval interval : ti.getIntervals(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY)) {
View Full Code Here


    this.low  = low;
    this.high = high;

    if (low != Double.NEGATIVE_INFINITY || high != Double.POSITIVE_INFINITY) {
      Graph vgraph = model.getGraph(currentView);
      for (Node n : vgraph.getNodes().toArray()) {
        TimeInterval ti = (TimeInterval)n.getNodeData().getAttributes().getValue(
            DynamicModel.TIMEINTERVAL_COLUMN);
        if (!ti.isInRange(low, high))
          vgraph.removeNode(n);
      }
      for (Edge e : vgraph.getEdges().toArray()) {
        TimeInterval ti = (TimeInterval)e.getEdgeData().getAttributes().getValue(
            DynamicModel.TIMEINTERVAL_COLUMN);
        if (!ti.isInRange(low, high))
          vgraph.removeEdge(e);
      }
    }
  }
View Full Code Here

    return getSnapshotGraph(new Interval(low, high), Estimator.FIRST);
  }

  @Override
  public Graph getSnapshotGraph(Interval interval, Estimator estimator) {
    Graph graph  = model.getGraph(sourceView);
    Graph vgraph = model.getGraph(currentView);
    for (Node n : graph.getNodes().toArray()) {
      TimeInterval ti = (TimeInterval)n.getNodeData().getAttributes().getValue(DynamicModel.TIMEINTERVAL_COLUMN);
                        if(ti == null && !vgraph.contains(n))
                                vgraph.addNode(n);
                        else if(ti != null && ti.getValue(interval, estimator) == null && vgraph.contains(n))
        vgraph.removeNode(n);
      else if (ti != null && ti.getValue(interval, estimator) != null && !vgraph.contains(n))
        vgraph.addNode(n);
    }
    for (Edge e : graph.getEdges().toArray()) {
      TimeInterval ti = (TimeInterval)e.getEdgeData().getAttributes().getValue(DynamicModel.TIMEINTERVAL_COLUMN);
                        if(ti == null && !vgraph.contains(e) &&
          vgraph.contains(e.getSource()) && vgraph.contains(e.getTarget()))
                                vgraph.addEdge(e);
                        else if(ti != null && ti.getValue(interval, estimator) == null && vgraph.contains(e))
        vgraph.removeEdge(e);
      else if (ti != null && ti.getValue(interval, estimator) != null && !vgraph.contains(e) &&
          vgraph.contains(e.getSource()) && vgraph.contains(e.getTarget()))
        vgraph.addEdge(e);
    }
    return vgraph;
  }
View Full Code Here

    return getStrongSnapshotGraph(new Interval(low, high));
  }

  @Override
  public Graph getStrongSnapshotGraph(Interval interval) {
    Graph graph  = model.getGraph(sourceView);
    Graph vgraph = model.getGraph(currentView);
    for (Node n : graph.getNodes().toArray()) {
      TimeInterval ti = (TimeInterval)n.getNodeData().getAttributes().getValue(DynamicModel.TIMEINTERVAL_COLUMN);
      if (ti.getValues(interval).size() < ti.getValues().size() && vgraph.contains(n))
        vgraph.removeNode(n);
      else if (ti.getValues(interval).size() == ti.getValues().size() && !vgraph.contains(n))
        vgraph.addNode(n);
    }
    for (Edge e : graph.getEdges().toArray()) {
      TimeInterval ti = (TimeInterval)e.getEdgeData().getAttributes().getValue(DynamicModel.TIMEINTERVAL_COLUMN);
      if (ti.getValues(interval).size() < ti.getValues().size() && vgraph.contains(e))
        vgraph.removeEdge(e);
      else if (ti.getValues(interval).size() == ti.getValues().size() && !vgraph.contains(e) &&
          vgraph.contains(e.getSource()) && vgraph.contains(e.getTarget()))
        vgraph.addEdge(e);
    }
    return vgraph;
  }
View Full Code Here

    }

    private void select(AbstractQueryImpl query) {
        FilterProcessor processor = new FilterProcessor();
        GraphModel graphModel = Lookup.getDefault().lookup(GraphController.class).getModel();
        Graph result = processor.process((AbstractQueryImpl) query, graphModel);
//        System.out.println("#Nodes: " + result.getNodeCount());
//        System.out.println("#Edges: " + result.getEdgeCount());
        if (running) {
            VisualizationController visController = Lookup.getDefault().lookup(VisualizationController.class);
            if (visController != null) {
                visController.selectNodes(result.getNodes().toArray());
                visController.selectEdges(result.getEdges().toArray());
            }
            GraphView view = result.getView();
            model.setCurrentResult(view);
        } else {
            //destroy view
            graphModel.destroyView(result.getView());
        }
    }
View Full Code Here

                    if (gc.getModel().getGraphVisible() instanceof DirectedGraph) {
                        DirectedGraph graph = (DirectedGraph) gc.getModel().getGraphVisible();
                        algorithm = new BellmanFordShortestPathAlgorithm(graph, n);
                        algorithm.compute();
                    } else {
                        Graph graph = gc.getModel().getGraphVisible();
                        algorithm = new DijkstraShortestPathAlgorithm(graph, n);
                        algorithm.compute();
                    }

                    //Color
View Full Code Here

                    edgePencilPanel.setStatus(NbBundle.getMessage(EdgePencil.class, "EdgePencil.status2"));
                } else {
                    color = edgePencilPanel.getColor();
                    weight = edgePencilPanel.getWeight();
                    GraphController gc = Lookup.getDefault().lookup(GraphController.class);
                    Graph graph = gc.getModel().getGraph();
                    boolean directed = graph instanceof DirectedGraph;
                    Edge edge = gc.getModel().factory().newEdge(sourceNode, n, weight, directed);
                    edge.getEdgeData().setR(color.getRed() / 255f);
                    edge.getEdgeData().setG(color.getGreen() / 255f);
                    edge.getEdgeData().setB(color.getBlue() / 255f);
                    graph.addEdge(edge);
                    sourceNode = null;
                    edgePencilPanel.setStatus(NbBundle.getMessage(EdgePencil.class, "EdgePencil.status1"));
                }
            }
        };
View Full Code Here

        ProjectController pj = Lookup.getDefault().lookup(ProjectController.class);
        pj.newProject();
        GraphController gc = Lookup.getDefault().lookup(GraphController.class);
        graphModel = gc.getModel();
        GraphFactory factory = graphModel.factory();
        Graph graph = gc.getModel().getUndirectedGraph();
        rootGraph = graph;

        //Add 8 nodes
        for (int i = 0; i < 8; i++) {
            Node node = factory.newNode();
            graph.addNode(node);
        }

        //Add edges
        graph.addEdge(factory.newEdge("0-1", graph.getNode(0), graph.getNode(1), 1f, false));
        graph.addEdge(factory.newEdge("1-3",graph.getNode(1), graph.getNode(3), 1f, false));
        graph.addEdge(factory.newEdge("3-2",graph.getNode(3), graph.getNode(2), 1f, false));
        graph.addEdge(factory.newEdge("2-0",graph.getNode(2), graph.getNode(0), 1f, false));
        graph.addEdge(factory.newEdge("4-5",graph.getNode(4), graph.getNode(5), 2f, false));
        graph.addEdge(factory.newEdge("5-7",graph.getNode(5), graph.getNode(7), 2f, false));
        graph.addEdge(factory.newEdge("7-6",graph.getNode(7), graph.getNode(6), 2f, false));
        graph.addEdge(factory.newEdge("6-4",graph.getNode(6), graph.getNode(4), 2f, false));
        graph.addEdge(factory.newEdge("3-4",graph.getNode(3), graph.getNode(4), 5f, false));

        //Query
        NodeDegreeFilter nodeDegreeFilter = new NodeDegreeFilter(3);
        simpleQuery = new FilterQueryImpl(nodeDegreeFilter);
View Full Code Here

    @Test
    public void testProcess() {
        FilterProcessor filterProcessor = new FilterProcessor();
        printGraph(rootGraph);
        Graph result = filterProcessor.process((AbstractQueryImpl) veryComplexQueryInter, graphModel);
        printGraph(result);
//        printGraph(rootGraph);
//        rootGraph.removeNode(rootGraph.getNode(0));
//        printGraph(rootGraph);
    }
View Full Code Here

        public FilterProperty[] getProperties() {
            return null;
        }

        public Graph filter(Graph[] graphs) {
            Graph maxGraph = graphs[0];
            int maxElements = 0;
            for (int i = 0; i < graphs.length; i++) {
                int count = graphs[i].getNodeCount();
                if (count > maxElements) {
                    maxGraph = graphs[i];
                    maxElements = count;
                }
            }
            for (int i = 0; i < graphs.length; i++) {
                if (graphs[i] != maxGraph) {
                    //Merge
                    for (Node n : graphs[i].getNodes().toArray()) {
                        maxGraph.addNode(n);
                    }
                    for (Edge e : graphs[i].getEdges().toArray()) {
                        maxGraph.addEdge(e);
                    }
                }
            }
            return maxGraph;
        }
View Full Code Here

TOP

Related Classes of org.gephi.graph.api.Graph

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.