Package org.gephi.graph.api

Examples of org.gephi.graph.api.GraphModel


       
    }
  
   @Test
    public void testSpecial2UndirectedGraphClusteringCoefficient() {
        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 edge23=graphModel.factory().newEdge(node2, node3, false);
        Edge edge31=graphModel.factory().newEdge(node3, node1, false);
        Edge edge14=graphModel.factory().newEdge(node1, node4, false);
        Edge edge45=graphModel.factory().newEdge(node4, node5, false);
        Edge edge51=graphModel.factory().newEdge(node5, node1, false);
        Edge edge16=graphModel.factory().newEdge(node1, node6, false);
        Edge edge67=graphModel.factory().newEdge(node6, node7, false);
        Edge edge71=graphModel.factory().newEdge(node7, node1, false);
        undirectedGraph.addEdge(edge12);
        undirectedGraph.addEdge(edge23);
        undirectedGraph.addEdge(edge31);
        undirectedGraph.addEdge(edge14);
        undirectedGraph.addEdge(edge45);
        undirectedGraph.addEdge(edge51);
        undirectedGraph.addEdge(edge16);
        undirectedGraph.addEdge(edge67);
        undirectedGraph.addEdge(edge71);
       
        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


       
    }
  
   @Test
    public void testSpecial3UndirectedGraphClusteringCoefficient() {
        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");
        undirectedGraph.addNode(node1);
        undirectedGraph.addNode(node2);
        undirectedGraph.addNode(node3);
        undirectedGraph.addNode(node4);
        undirectedGraph.addNode(node5);
        undirectedGraph.addNode(node6);
        Edge edge12=graphModel.factory().newEdge(node1, node2, false);
        Edge edge23=graphModel.factory().newEdge(node2, node3, false);
        Edge edge31=graphModel.factory().newEdge(node3, node1, false);
        Edge edge14=graphModel.factory().newEdge(node1, node4, false);
        Edge edge25=graphModel.factory().newEdge(node2, node5, false);
        Edge edge36=graphModel.factory().newEdge(node3, node6, false);
        undirectedGraph.addEdge(edge12);
        undirectedGraph.addEdge(edge23);
        undirectedGraph.addEdge(edge31);
        undirectedGraph.addEdge(edge14);
        undirectedGraph.addEdge(edge25);
        undirectedGraph.addEdge(edge36);;
       
        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 testTriangleGraphClusteringCoefficient() {
        GraphModel graphModel=GraphGenerator.generateCompleteUndirectedGraph(3);
        Graph hgraph = graphModel.getGraph();

        ClusteringCoefficient cc = new ClusteringCoefficient();
        ArrayWrapper[] network = new ArrayWrapper[3];

        int[] triangles = new int[3];
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

        assertEquals(avClusteringCoefficient, 0.5);
    }
  
   @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

        assertEquals(avClusteringCoefficient, 1.);
    }
  
   @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

        assertTrue(Math.abs(avClusteringCoefficient-res)<diff);
    }
  
    @Test
    public void testTriangleNonCompleteDirectedGraphClusteringCoefficient() {
        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 edge13=graphModel.factory().newEdge(node1, node3);
        
        directedGraph.addEdge(edge12);
        directedGraph.addEdge(edge21);
        directedGraph.addEdge(edge23);
        directedGraph.addEdge(edge32);
        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

    private boolean sendUnsetValueEventsForRemovedColumn(AttributeColumn column) {
        if (this.model.getWorkspace() == null) {
            return false;
        }

        GraphModel graphModel = Lookup.getDefault().lookup(GraphController.class).getModel(this.model.getWorkspace());
        Attributes[] rows;

        if (AttributeUtils.getDefault().isNodeColumn(column)) {
            Node[] nodes = graphModel.getGraph().getNodes().toArray();
            rows = new Attributes[nodes.length];

            for (int i = 0; i < nodes.length; i++) {
                rows[i] = nodes[i].getAttributes();
            }
        } else if (AttributeUtils.getDefault().isEdgeColumn(column)) {
            Edge[] edges = graphModel.getGraph().getEdges().toArray();
            rows = new Attributes[edges.length];

            for (int i = 0; i < edges.length; i++) {
                rows[i] = edges[i].getAttributes();
            }
        } else if (AttributeUtils.getDefault().isGraphColumn(column)) {
            rows = new Attributes[]{graphModel.getGraph().getAttributes()};
        } else {
            return false;
        }
       
        int columnIndex = column.getIndex();
View Full Code Here

        assertTrue(Math.abs(closeness[index7] - res) < diff);
    }

    @Test
    public void testSpecial2UndirectedGraphBetweenness() {
        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");
        Node node8 = graphModel.factory().newNode("7");
        undirectedGraph.addNode(node1);
        undirectedGraph.addNode(node2);
        undirectedGraph.addNode(node3);
        undirectedGraph.addNode(node4);
        undirectedGraph.addNode(node5);
        undirectedGraph.addNode(node6);
        undirectedGraph.addNode(node7);
        undirectedGraph.addNode(node8);
        Edge edge12 = graphModel.factory().newEdge(node1, node2, false);
        Edge edge13 = graphModel.factory().newEdge(node1, node3, false);
        Edge edge34 = graphModel.factory().newEdge(node3, node4, false);
        Edge edge24 = graphModel.factory().newEdge(node2, node4, false);
        Edge edge56 = graphModel.factory().newEdge(node5, node6, false);
        Edge edge67 = graphModel.factory().newEdge(node6, node7, false);
        Edge edge78 = graphModel.factory().newEdge(node7, node8, false);
        Edge edge85 = graphModel.factory().newEdge(node8, node5, false);
        Edge edge45 = graphModel.factory().newEdge(node4, node5, false);
        undirectedGraph.addEdge(edge12);
        undirectedGraph.addEdge(edge13);
        undirectedGraph.addEdge(edge34);
        undirectedGraph.addEdge(edge24);
        undirectedGraph.addEdge(edge56);
        undirectedGraph.addEdge(edge67);
        undirectedGraph.addEdge(edge78);
        undirectedGraph.addEdge(edge85);
        undirectedGraph.addEdge(edge45);

        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);

        Node n4 = undirectedGraph.getNode("3");
        Node n6 = undirectedGraph.getNode("5");
        Node n7 = undirectedGraph.getNode("6");
View Full Code Here

        assertEquals(betweenness[index7], 0.5);
    }

    @Test
    public void testSpecial2UndirectedGraphCloseness() {
        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");
        Node node8 = graphModel.factory().newNode("7");
        undirectedGraph.addNode(node1);
        undirectedGraph.addNode(node2);
        undirectedGraph.addNode(node3);
        undirectedGraph.addNode(node4);
        undirectedGraph.addNode(node5);
        undirectedGraph.addNode(node6);
        undirectedGraph.addNode(node7);
        undirectedGraph.addNode(node8);
        Edge edge12 = graphModel.factory().newEdge(node1, node2, false);
        Edge edge13 = graphModel.factory().newEdge(node1, node3, false);
        Edge edge34 = graphModel.factory().newEdge(node3, node4, false);
        Edge edge24 = graphModel.factory().newEdge(node2, node4, false);
        Edge edge56 = graphModel.factory().newEdge(node5, node6, false);
        Edge edge67 = graphModel.factory().newEdge(node6, node7, false);
        Edge edge78 = graphModel.factory().newEdge(node7, node8, false);
        Edge edge85 = graphModel.factory().newEdge(node8, node5, false);
        Edge edge45 = graphModel.factory().newEdge(node4, node5, false);
        undirectedGraph.addEdge(edge12);
        undirectedGraph.addEdge(edge13);
        undirectedGraph.addEdge(edge34);
        undirectedGraph.addEdge(edge24);
        undirectedGraph.addEdge(edge56);
        undirectedGraph.addEdge(edge67);
        undirectedGraph.addEdge(edge78);
        undirectedGraph.addEdge(edge85);
        undirectedGraph.addEdge(edge45);

        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 index2 = indicies.get(node2);

        double res = 2.2857;
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.