Package org.gephi.graph.api

Examples of org.gephi.graph.api.DirectedGraph


                    }
                    GraphController gc = Lookup.getDefault().lookup(GraphController.class);

                    AbstractShortestPathAlgorithm algorithm;
                    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);
View Full Code Here


        return null;
    }

    public NodeRanking getInDegreeRanking() {
        GraphModel model = Lookup.getDefault().lookup(GraphController.class).getModel();
        DirectedGraph graph = model.getDirectedGraphVisible();
        NodeRanking degreeRanking = RankingFactory.getNodeInDegreeRanking(graph);
        if (degreeRanking.getMinimumValue() != null && degreeRanking.getMaximumValue() != null && !degreeRanking.getMinimumValue().equals(degreeRanking.getMaximumValue())) {
            return degreeRanking;
        }
        return null;
View Full Code Here

        return null;
    }

    public NodeRanking getOutDegreeRanking() {
        GraphModel model = Lookup.getDefault().lookup(GraphController.class).getModel();
        DirectedGraph graph = model.getDirectedGraphVisible();
        NodeRanking degreeRanking = RankingFactory.getNodeOutDegreeRanking(graph);
        if (degreeRanking.getMinimumValue() != null && degreeRanking.getMaximumValue() != null && !degreeRanking.getMinimumValue().equals(degreeRanking.getMaximumValue())) {
            return degreeRanking;
        }
        return null;
View Full Code Here

        if (degreeRanking.getMinimumValue() != null && degreeRanking.getMaximumValue() != null && !degreeRanking.getMinimumValue().equals(degreeRanking.getMaximumValue())) {
            rankingList.add(degreeRanking);
        }

        if (model.isDirected()) {
            DirectedGraph directedGraph = model.getDirectedGraphVisible();
            NodeRanking inDegreeRanking = RankingFactory.getNodeInDegreeRanking(directedGraph);
            if (inDegreeRanking.getMinimumValue() != null && inDegreeRanking.getMaximumValue() != null && !inDegreeRanking.getMinimumValue().equals(inDegreeRanking.getMaximumValue())) {
                rankingList.add(inDegreeRanking);
            }
            NodeRanking outDegreeRanking = RankingFactory.getNodeOutDegreeRanking(directedGraph);
View Full Code Here

        projectController.newProject();
        AttributeController attributeController = Lookup.getDefault().lookup(AttributeController.class);
        attributeModel = attributeController.getModel();
        GraphController graphController = Lookup.getDefault().lookup(GraphController.class);
        graphModel = graphController.getModel();
        DirectedGraph graph = graphModel.getDirectedGraph();

        for (int i = 0; i < NODES; i++) {
            Node newNode = graphModel.factory().newNode();
            graph.addNode(newNode);
        }

        Random random = new Random();
        int j = 0;
        while (j < EDGES) {
            Node source = graph.getNode(random.nextInt(NODES));
            Node target = graph.getNode(random.nextInt(NODES));
            if (graph.getEdge(source, target) == null) {
                graph.addEdge(graphModel.factory().newEdge(source, target));
                j++;
            }
        }
    }
View Full Code Here

                }
                writer.append(EOL);
            }
        } else {
            if (graph instanceof DirectedGraph) {
                DirectedGraph directedGraph = (DirectedGraph) graph;
                Node[] nodes = graph.getNodes().toArray();
                for (Node n : nodes) {
                    if (cancel) {
                        break;
                    }
                    writeMatrixNode(n, true);
                    for (int j = 0; j < nodes.length; j++) {
                        Node m = nodes[j];
                        Edge e = directedGraph.getEdge(n, m);
                        e = e == null ? ((HierarchicalDirectedGraph) directedGraph).getMetaEdge(n, m) : e;
                        writeEdge(e, j < nodes.length - 1);
                    }
                    Progress.progress(progressTicket);
                    writer.append(EOL);
View Full Code Here

        return graph instanceof DirectedGraph;
    }

    @Override
    public boolean evaluate(Graph graph, Edge edge) {
        DirectedGraph directedGraph = (DirectedGraph) graph;

        //Make sure the edge is not  self loop
        if (!edge.isSelfLoop()) {
            //Get the potential mutual edge
            Edge mutualEdge = directedGraph.getEdge(edge.getTarget(), edge.getSource());

            //Remove the mutual edge if exists
            //Make sure only one of the two mutual edges will bre removed
            if (mutualEdge != null && mutualEdge.getId() < edge.getId()) {
                return false;
View Full Code Here

  
   @Test
    public void testSpecial1DirectedGraphClusteringCoefficient() {
        GraphModel graphModel=Lookup.getDefault().lookup(GraphController.class).getGraphModel();
       
        DirectedGraph directedGraph=graphModel.getDirectedGraph();
       
        Node node1=graphModel.factory().newNode("0");
        Node node2=graphModel.factory().newNode("1");
        Node node3=graphModel.factory().newNode("2");
        Node node4=graphModel.factory().newNode("3");
       
        directedGraph.addNode(node1);
        directedGraph.addNode(node2);
        directedGraph.addNode(node3);
        directedGraph.addNode(node4);
       
        Edge edge12=graphModel.factory().newEdge(node1, node2);
        Edge edge23=graphModel.factory().newEdge(node2, node3);
        Edge edge24=graphModel.factory().newEdge(node2, node4);
        Edge edge31=graphModel.factory().newEdge(node3, node1);
        Edge edge34=graphModel.factory().newEdge(node3, node4);
        Edge edge41=graphModel.factory().newEdge(node4, node1);
        
        directedGraph.addEdge(edge12);
        directedGraph.addEdge(edge23);
        directedGraph.addEdge(edge24);
        directedGraph.addEdge(edge31);
        directedGraph.addEdge(edge34);
        directedGraph.addEdge(edge41);
       
       
        DirectedGraph hgraph = graphModel.getDirectedGraph();
       
        ClusteringCoefficient cc = new ClusteringCoefficient();
        ArrayWrapper[] network = new ArrayWrapper[4];
        int[] triangles = new int[4];
        double[] nodeClustering = new double[4];
View Full Code Here

  
   @Test
    public void testTriangleDirectedGraphClusteringCoefficient() {
        GraphModel graphModel=Lookup.getDefault().lookup(GraphController.class).getGraphModel();
       
        DirectedGraph directedGraph=graphModel.getDirectedGraph();
       
        Node node1=graphModel.factory().newNode("0");
        Node node2=graphModel.factory().newNode("1");
        Node node3=graphModel.factory().newNode("2");
       
        directedGraph.addNode(node1);
        directedGraph.addNode(node2);
        directedGraph.addNode(node3);
       
        Edge edge12=graphModel.factory().newEdge(node1, node2);
        Edge edge21=graphModel.factory().newEdge(node2, node1);
        Edge edge23=graphModel.factory().newEdge(node2, node3);
        Edge edge32=graphModel.factory().newEdge(node3, node2);
        Edge edge31=graphModel.factory().newEdge(node3, node1);
        Edge edge13=graphModel.factory().newEdge(node1, node3);
        
        directedGraph.addEdge(edge12);
        directedGraph.addEdge(edge21);
        directedGraph.addEdge(edge23);
        directedGraph.addEdge(edge32);
        directedGraph.addEdge(edge31);
        directedGraph.addEdge(edge13);
       
       
        DirectedGraph hgraph = graphModel.getDirectedGraph();
       
        ClusteringCoefficient cc = new ClusteringCoefficient();
        ArrayWrapper[] network = new ArrayWrapper[3];
        int[] triangles = new int[3];
        double[] nodeClustering = new double[3];
View Full Code Here

  
   @Test
    public void testSpecial2DirectedGraphClusteringCoefficient() {
        GraphModel graphModel=Lookup.getDefault().lookup(GraphController.class).getGraphModel();
       
        DirectedGraph directedGraph=graphModel.getDirectedGraph();
       
        Node node1=graphModel.factory().newNode("0");
        Node node2=graphModel.factory().newNode("1");
        Node node3=graphModel.factory().newNode("2");
        Node node4=graphModel.factory().newNode("3");
       
        directedGraph.addNode(node1);
        directedGraph.addNode(node2);
        directedGraph.addNode(node3);
        directedGraph.addNode(node4);
       
        Edge edge21=graphModel.factory().newEdge(node2, node1);
        Edge edge24=graphModel.factory().newEdge(node2, node4);
        Edge edge31=graphModel.factory().newEdge(node3, node1);
        Edge edge32=graphModel.factory().newEdge(node3, node2);
        Edge edge43=graphModel.factory().newEdge(node4, node3);
        
        directedGraph.addEdge(edge21);
        directedGraph.addEdge(edge24);
        directedGraph.addEdge(edge31);
        directedGraph.addEdge(edge32);
        directedGraph.addEdge(edge43);
       
       
        DirectedGraph hgraph = graphModel.getDirectedGraph();
       
        ClusteringCoefficient cc = new ClusteringCoefficient();
        ArrayWrapper[] network = new ArrayWrapper[4];
        int[] triangles = new int[4];
        double[] nodeClustering = new double[4];
View Full Code Here

TOP

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

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.