Package org.gephi.graph.api

Examples of org.gephi.graph.api.GraphModel


        assertEquals(closeness[index3], 1.5);
    }

    @Test
    public void testSpecial1UndirectedGraphBetweenness() {
        GraphModel graphModel = Lookup.getDefault().lookup(GraphController.class).getGraphModel();
        UndirectedGraph undirectedGraph = graphModel.getUndirectedGraph();
        Node node1 = graphModel.factory().newNode("0");
        Node node2 = graphModel.factory().newNode("1");
        Node node3 = graphModel.factory().newNode("2");
        Node node4 = graphModel.factory().newNode("3");
        Node node5 = graphModel.factory().newNode("4");
        Node node6 = graphModel.factory().newNode("5");
        Node node7 = graphModel.factory().newNode("6");
        undirectedGraph.addNode(node1);
        undirectedGraph.addNode(node2);
        undirectedGraph.addNode(node3);
        undirectedGraph.addNode(node4);
        undirectedGraph.addNode(node5);
        undirectedGraph.addNode(node6);
        undirectedGraph.addNode(node7);
        Edge edge12 = graphModel.factory().newEdge(node1, node2, false);
        Edge edge13 = graphModel.factory().newEdge(node1, node3, false);
        Edge edge14 = graphModel.factory().newEdge(node1, node4, false);
        Edge edge15 = graphModel.factory().newEdge(node1, node5, false);
        Edge edge16 = graphModel.factory().newEdge(node1, node6, false);
        Edge edge27 = graphModel.factory().newEdge(node2, node7, false);
        Edge edge37 = graphModel.factory().newEdge(node3, node7, false);
        Edge edge47 = graphModel.factory().newEdge(node4, node7, false);
        Edge edge57 = graphModel.factory().newEdge(node5, node7, false);
        Edge edge67 = graphModel.factory().newEdge(node6, node7, false);
        undirectedGraph.addEdge(edge12);
        undirectedGraph.addEdge(edge13);
        undirectedGraph.addEdge(edge14);
        undirectedGraph.addEdge(edge15);
        undirectedGraph.addEdge(edge16);
        undirectedGraph.addEdge(edge27);
        undirectedGraph.addEdge(edge37);
        undirectedGraph.addEdge(edge47);
        undirectedGraph.addEdge(edge57);
        undirectedGraph.addEdge(edge67);

        GraphDistance d = new GraphDistance();
        d.initializeStartValues();
        UndirectedGraph hierarchicalUndirectedGraph = graphModel.getUndirectedGraph();
        HashMap<Node, Integer> indicies = d.createIndiciesMap(hierarchicalUndirectedGraph);

        HashMap<String, double[]> metricsMap = (HashMap) d.calculateDistanceMetrics(graphModel.getGraph(), indicies, false, false);
        double[] betweenness = metricsMap.get(GraphDistance.BETWEENNESS);

        int index1 = indicies.get(node1);
        int index3 = indicies.get(node3);
View Full Code Here


        assertEquals(betweenness[index3], 0.2);
    }

    @Test
    public void testSpecial1UndirectedGraphCloseness() {
        GraphModel graphModel = Lookup.getDefault().lookup(GraphController.class).getGraphModel();
        UndirectedGraph undirectedGraph = graphModel.getUndirectedGraph();
        Node node1 = graphModel.factory().newNode("0");
        Node node2 = graphModel.factory().newNode("1");
        Node node3 = graphModel.factory().newNode("2");
        Node node4 = graphModel.factory().newNode("3");
        Node node5 = graphModel.factory().newNode("4");
        Node node6 = graphModel.factory().newNode("5");
        Node node7 = graphModel.factory().newNode("6");
        undirectedGraph.addNode(node1);
        undirectedGraph.addNode(node2);
        undirectedGraph.addNode(node3);
        undirectedGraph.addNode(node4);
        undirectedGraph.addNode(node5);
        undirectedGraph.addNode(node6);
        undirectedGraph.addNode(node7);
        Edge edge12 = graphModel.factory().newEdge(node1, node2, false);
        Edge edge13 = graphModel.factory().newEdge(node1, node3, false);
        Edge edge14 = graphModel.factory().newEdge(node1, node4, false);
        Edge edge15 = graphModel.factory().newEdge(node1, node5, false);
        Edge edge16 = graphModel.factory().newEdge(node1, node6, false);
        Edge edge27 = graphModel.factory().newEdge(node2, node7, false);
        Edge edge37 = graphModel.factory().newEdge(node3, node7, false);
        Edge edge47 = graphModel.factory().newEdge(node4, node7, false);
        Edge edge57 = graphModel.factory().newEdge(node5, node7, false);
        Edge edge67 = graphModel.factory().newEdge(node6, node7, false);
        undirectedGraph.addEdge(edge12);
        undirectedGraph.addEdge(edge13);
        undirectedGraph.addEdge(edge14);
        undirectedGraph.addEdge(edge15);
        undirectedGraph.addEdge(edge16);
        undirectedGraph.addEdge(edge27);
        undirectedGraph.addEdge(edge37);
        undirectedGraph.addEdge(edge47);
        undirectedGraph.addEdge(edge57);
        undirectedGraph.addEdge(edge67);

        GraphDistance d = new GraphDistance();
        d.initializeStartValues();
        UndirectedGraph hierarchicalUndirectedGraph = graphModel.getUndirectedGraph();
        HashMap<Node, Integer> indicies = d.createIndiciesMap(hierarchicalUndirectedGraph);

        HashMap<String, double[]> metricsMap = (HashMap) d.calculateDistanceMetrics(graphModel.getGraph(), indicies, false, false);
        double[] closeness = metricsMap.get(GraphDistance.CLOSENESS);

        int index7 = indicies.get(node7);

        double res = 1.1667;
View Full Code Here

    }

    @Override
    public Ranking[] buildRanking(RankingModel model) {
        Workspace workspace = model.getWorkspace();
        GraphModel graphModel = graphController.getGraphModel(workspace);

        return new Ranking[]{new DegreeRanking(Ranking.NODE_ELEMENT, graphModel, model)};
    }
View Full Code Here

            return minimum;
        }

        @Override
        protected DegreeRanking clone() {
            GraphModel graphModel = graph.getView().getGraphModel();
            return new DegreeRanking(elementType, graphModel, rankingModel);
        }
View Full Code Here

        pc.closeCurrentProject();
    }
   
    @Test
    public void testOneNodeClusteringCoefficient() {
        GraphModel graphModel=GraphGenerator.generateCompleteUndirectedGraph(1);
        Graph hgraph = graphModel.getGraph();

        ClusteringCoefficient cc = new ClusteringCoefficient();
        ArrayWrapper[] network = new ArrayWrapper[1];
        int[] triangles = new int[1];
        double[] nodeClustering = new double[1];
View Full Code Here

        assertEquals(avClusteringCoefficient, Double.NaN);
    }
   
    @Test
    public void testTwoConectedNodesClusteringCoefficient() {
        GraphModel graphModel=GraphGenerator.generateCompleteUndirectedGraph(2);
        Graph hgraph = graphModel.getGraph();

        ClusteringCoefficient cc = new ClusteringCoefficient();
        ArrayWrapper[] network = new ArrayWrapper[2];
        int[] triangles = new int[2];
        double[] nodeClustering = new double[2];
View Full Code Here

        assertEquals(avClusteringCoefficient, Double.NaN);
    }
   
    @Test
    public void testNullGraphClusteringCoefficient() {
        GraphModel graphModel=GraphGenerator.generateNullUndirectedGraph(5);
        Graph hgraph = graphModel.getGraph();

        ClusteringCoefficient cc = new ClusteringCoefficient();
        ArrayWrapper[] network = new ArrayWrapper[5];
        int[] triangles = new int[5];
        double[] nodeClustering = new double[5];
View Full Code Here

        assertEquals(avClusteringCoefficient, Double.NaN);
    }
   
   @Test
    public void testCompleteGraphClusteringCoefficient() {
        GraphModel graphModel=GraphGenerator.generateCompleteUndirectedGraph(5);
        Graph hgraph = graphModel.getGraph();

        ClusteringCoefficient cc = new ClusteringCoefficient();
        ArrayWrapper[] network = new ArrayWrapper[5];
        int[] triangles = new int[5];
        double[] nodeClustering = new double[5];
View Full Code Here

        assertEquals(avClusteringCoefficient, 1.0);
    }
  
   @Test
    public void testStarGraphClusteringCoefficient() {
        GraphModel graphModel=GraphGenerator.generateStarUndirectedGraph(5);
        Graph hgraph = graphModel.getGraph();

        ClusteringCoefficient cc = new ClusteringCoefficient();
        ArrayWrapper[] network = new ArrayWrapper[6];
        int[] triangles = new int[6];
        double[] nodeClustering = new double[6];
View Full Code Here

    }
 
  
   @Test
    public void testSpecial1UndirectedGraphClusteringCoefficient() {
        GraphModel graphModel=Lookup.getDefault().lookup(GraphController.class).getGraphModel();
        UndirectedGraph undirectedGraph=graphModel.getUndirectedGraph();
        Node node1=graphModel.factory().newNode("0");
        Node node2=graphModel.factory().newNode("1");
        Node node3=graphModel.factory().newNode("2");
        Node node4=graphModel.factory().newNode("3");
        Node node5=graphModel.factory().newNode("4");
        Node node6=graphModel.factory().newNode("5");
        Node node7=graphModel.factory().newNode("6");
        undirectedGraph.addNode(node1);
        undirectedGraph.addNode(node2);
        undirectedGraph.addNode(node3);
        undirectedGraph.addNode(node4);
        undirectedGraph.addNode(node5);
        undirectedGraph.addNode(node6);
        undirectedGraph.addNode(node7);
        Edge edge12=graphModel.factory().newEdge(node1, node2, false);
        Edge edge13=graphModel.factory().newEdge(node1, node3, false);
        Edge edge14=graphModel.factory().newEdge(node1, node4, false);
        Edge edge15=graphModel.factory().newEdge(node1, node5, false);
        Edge edge16=graphModel.factory().newEdge(node1, node6, false);
        Edge edge17=graphModel.factory().newEdge(node1, node7, false);
        Edge edge23=graphModel.factory().newEdge(node2, node3, false);
        Edge edge34=graphModel.factory().newEdge(node3, node4, false);
        Edge edge45=graphModel.factory().newEdge(node4, node5, false);
        Edge edge56=graphModel.factory().newEdge(node5, node6, false);
        Edge edge67=graphModel.factory().newEdge(node6, node7, false);
        Edge edge72=graphModel.factory().newEdge(node7, node2, false);
        undirectedGraph.addEdge(edge12);
        undirectedGraph.addEdge(edge13);
        undirectedGraph.addEdge(edge14);
        undirectedGraph.addEdge(edge15);
        undirectedGraph.addEdge(edge16);
        undirectedGraph.addEdge(edge17);
        undirectedGraph.addEdge(edge23);
        undirectedGraph.addEdge(edge34);
        undirectedGraph.addEdge(edge45);
        undirectedGraph.addEdge(edge56);
        undirectedGraph.addEdge(edge67);
        undirectedGraph.addEdge(edge72);
       
        Graph hgraph = graphModel.getGraph();
        ClusteringCoefficient cc = new ClusteringCoefficient();

        ArrayWrapper[] network = new ArrayWrapper[7];
        int[] triangles = new int[7];
        double[] nodeClustering = new double[7];
View Full Code Here

TOP

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

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.