Package org.gephi.graph.api

Examples of org.gephi.graph.api.UndirectedGraph


    public void testCyclic6GraphBetweenness() {
        GraphModel graphModel = GraphGenerator.generateCyclicUndirectedGraph(6);

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

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

        Node n2 = undirectedGraph.getNode("1");
        int index2 = indicies.get(n2);

        assertEquals(betweenness[index2], 2.0);
    }
View Full Code Here


    public void testCyclic5GraphCloseness() {
        GraphModel graphModel = GraphGenerator.generateCyclicUndirectedGraph(5);

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

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

        Node n3 = undirectedGraph.getNode("2");
        int index3 = indicies.get(n3);

        assertEquals(closeness[index3], 1.5);
    }
View Full Code Here

    }

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

*/
public class GraphGenerator {

    public static GraphModel generateNullUndirectedGraph(int n) {
        GraphModel graphModel = Lookup.getDefault().lookup(GraphController.class).getGraphModel();
        UndirectedGraph undirectedGraph = graphModel.getUndirectedGraph();
        for (int i = 0; i < n; i++) {
            Node currentNode = graphModel.factory().newNode(((Integer) i).toString());
            undirectedGraph.addNode(currentNode);
        }
        return graphModel;
    }
View Full Code Here

        return graphModel;
    }

    public static GraphModel generateCompleteUndirectedGraph(int n) {
        GraphModel graphModel = Lookup.getDefault().lookup(GraphController.class).getGraphModel();
        UndirectedGraph undirectedGraph = graphModel.getUndirectedGraph();
        Node[] nodes = new Node[n];
        for (int i = 0; i < n; i++) {
            Node currentNode = graphModel.factory().newNode(((Integer) i).toString());
            nodes[i] = currentNode;
            undirectedGraph.addNode(currentNode);
        }
        for (int i = 0; i < n - 1; i++) {
            for (int j = i + 1; j < n; j++) {
                Edge currentEdge = graphModel.factory().newEdge(nodes[i], nodes[j], false);
                undirectedGraph.addEdge(currentEdge);
            }
        }
        return graphModel;
    }
View Full Code Here

        return graphModel;
    }

    public static GraphModel generatePathUndirectedGraph(int n) {
        GraphModel graphModel = Lookup.getDefault().lookup(GraphController.class).getGraphModel();
        UndirectedGraph undirectedGraph = graphModel.getUndirectedGraph();
        if (n <= 0) {
            return graphModel;
        }
        Node firstNode = graphModel.factory().newNode("0");
        undirectedGraph.addNode(firstNode);
        Node prevNode = firstNode;
        for (int i = 1; i < n; i++) {
            Node currentNode = graphModel.factory().newNode(((Integer) i).toString());
            undirectedGraph.addNode(currentNode);
            Edge currentEdge = graphModel.factory().newEdge(prevNode, currentNode, false);
            undirectedGraph.addEdge(currentEdge);
            prevNode = currentNode;
        }
        return graphModel;
    }
View Full Code Here

        return graphModel;
    }

    public static GraphModel generateCyclicUndirectedGraph(int n) {
        GraphModel graphModel = Lookup.getDefault().lookup(GraphController.class).getGraphModel();
        UndirectedGraph undirectedGraph = graphModel.getUndirectedGraph();
        if (n <= 0) {
            return graphModel;
        }
        Node firstNode = graphModel.factory().newNode("0");
        undirectedGraph.addNode(firstNode);
        Node prevNode = firstNode;
        for (int i = 1; i < n; i++) {
            Node currentNode = graphModel.factory().newNode(((Integer) i).toString());
            undirectedGraph.addNode(currentNode);
            Edge currentEdge = graphModel.factory().newEdge(prevNode, currentNode, false);
            undirectedGraph.addEdge(currentEdge);
            prevNode = currentNode;
        }
        Edge currentEdge = graphModel.factory().newEdge(prevNode, firstNode, false);
        undirectedGraph.addEdge(currentEdge);
        return graphModel;
    }
View Full Code Here

    }

    //generates graph from n+1 nodes
    public static GraphModel generateStarUndirectedGraph(int n) {
        GraphModel graphModel = Lookup.getDefault().lookup(GraphController.class).getGraphModel();
        UndirectedGraph undirectedGraph = graphModel.getUndirectedGraph();
        Node firstNode = graphModel.factory().newNode("0");
        undirectedGraph.addNode(firstNode);
        for (int i = 1; i <= n; i++) {
            Node currentNode = graphModel.factory().newNode(((Integer) i).toString());
            undirectedGraph.addNode(currentNode);
            Edge currentEdge = graphModel.factory().newEdge(firstNode, currentNode, false);
            undirectedGraph.addEdge(currentEdge);
        }
        return graphModel;
    }
View Full Code Here

    }

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

    }

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

TOP

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

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.