Package org.gephi.graph.api

Examples of org.gephi.graph.api.UndirectedGraph


                    }
                    Progress.progress(progressTicket);
                    writer.append(EOL);
                }
            } else if (graph instanceof UndirectedGraph) {
                UndirectedGraph undirectedGraph = (UndirectedGraph) 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 = undirectedGraph.getEdge(n, m);
                        e = e == null ? ((HierarchicalUndirectedGraph) undirectedGraph).getMetaEdge(n, m) : e;
                        writeEdge(e, j < nodes.length - 1);
                    }
                    Progress.progress(progressTicket);
                    writer.append(EOL);
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];
View Full Code Here

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

    }

    @Test
    public void testSpecial2UndirectedGraphGiantComponent() {
        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");
        Node node9 = graphModel.factory().newNode("8");
        undirectedGraph.addNode(node1);
        undirectedGraph.addNode(node2);
        undirectedGraph.addNode(node3);
        undirectedGraph.addNode(node4);
        undirectedGraph.addNode(node5);
        undirectedGraph.addNode(node6);
        undirectedGraph.addNode(node7);
        undirectedGraph.addNode(node8);
        undirectedGraph.addNode(node9);
        Edge edge12 = graphModel.factory().newEdge(node1, node2, false);
        Edge edge23 = graphModel.factory().newEdge(node2, node3, false);
        Edge edge45 = graphModel.factory().newEdge(node4, node5, false);
        Edge edge56 = graphModel.factory().newEdge(node5, node6, false);
        Edge edge64 = graphModel.factory().newEdge(node6, node4, false);
        Edge edge75 = graphModel.factory().newEdge(node7, node5, false);
        undirectedGraph.addEdge(edge12);
        undirectedGraph.addEdge(edge23);
        undirectedGraph.addEdge(edge45);
        undirectedGraph.addEdge(edge56);
        undirectedGraph.addEdge(edge64);
        undirectedGraph.addEdge(edge75);

        UndirectedGraph graph = graphModel.getUndirectedGraph();

        ConnectedComponents c = new ConnectedComponents();
        HashMap<Node, Integer> indicies = c.createIndiciesMap(graph);
        LinkedList<LinkedList<Node>> components = c.computeWeeklyConnectedComponents(graph, indicies);
        c.fillComponentSizeList(components);
View Full Code Here

    }

    @Test
    public void testTwoConnectedNodesModularity() {
        GraphModel graphModel = GraphGenerator.generateCompleteUndirectedGraph(2);
        UndirectedGraph hgraph = graphModel.getUndirectedGraph();

        Modularity mod = new Modularity();

        Modularity.CommunityStructure theStructure = mod.new CommunityStructure(hgraph);
        int[] comStructure = new int[hgraph.getNodeCount()];

        HashMap<String, Double> modularityValues = mod.computeModularity(hgraph, theStructure, comStructure,
                1., true, false);

        double modValue = modularityValues.get("modularity");
View Full Code Here

    }

    @Test
    public void testGraphWithouLinksModularity() {
        GraphModel graphModel = GraphGenerator.generateNullUndirectedGraph(5);
        UndirectedGraph hgraph = graphModel.getUndirectedGraph();

        Modularity mod = new Modularity();

        Modularity.CommunityStructure theStructure = mod.new CommunityStructure(hgraph);
        int[] comStructure = new int[hgraph.getNodeCount()];

        HashMap<String, Double> modularityValues = mod.computeModularity(hgraph, theStructure, comStructure,
                1., true, false);

        double modValue = modularityValues.get("modularity");
View Full Code Here

    }

    @Test
    public void testComputeBarbellGraphModularityNormalResolution() {
        GraphModel graphModel = GraphGenerator.generateCompleteUndirectedGraph(4);
        UndirectedGraph undirectedGraph = graphModel.getUndirectedGraph();
        Node[] nodes = new Node[4];
        for (int i = 0; i < 4; i++) {
            Node currentNode = graphModel.factory().newNode(((Integer) (i + 4)).toString());
            nodes[i] = currentNode;
            undirectedGraph.addNode(currentNode);
        }
        for (int i = 0; i < 3; i++) {
            for (int j = i + 1; j < 4; j++) {
                Edge currentEdge = graphModel.factory().newEdge(nodes[i], nodes[j], false);
                undirectedGraph.addEdge(currentEdge);
            }
        }
        Edge currentEdge = graphModel.factory().newEdge(undirectedGraph.getNode("0"), undirectedGraph.getNode("5"), false);
        undirectedGraph.addEdge(currentEdge);
        UndirectedGraph graph = graphModel.getUndirectedGraph();

        Modularity mod = new Modularity();

        Modularity.CommunityStructure theStructure = mod.new CommunityStructure(graph);
        int[] comStructure = new int[graph.getNodeCount()];

        HashMap<String, Double> modularityValues = mod.computeModularity(graph, theStructure, comStructure,
                1., true, false);

        double modValue = modularityValues.get("modularity");
View Full Code Here

    }

    @Test
    public void testComputeBarbellGraphHighResolution() {
        GraphModel graphModel = GraphGenerator.generateCompleteUndirectedGraph(4);
        UndirectedGraph undirectedGraph = graphModel.getUndirectedGraph();
        Node[] nodes = new Node[4];
        for (int i = 0; i < 4; i++) {
            Node currentNode = graphModel.factory().newNode(((Integer) (i + 4)).toString());
            nodes[i] = currentNode;
            undirectedGraph.addNode(currentNode);
        }
        for (int i = 0; i < 3; i++) {
            for (int j = i + 1; j < 4; j++) {
                Edge currentEdge = graphModel.factory().newEdge(nodes[i], nodes[j], false);
                undirectedGraph.addEdge(currentEdge);
            }
        }
        Edge currentEdge = graphModel.factory().newEdge(undirectedGraph.getNode("0"), undirectedGraph.getNode("5"), false);
        undirectedGraph.addEdge(currentEdge);
        UndirectedGraph graph = graphModel.getUndirectedGraph();

        Modularity mod = new Modularity();

        Modularity.CommunityStructure theStructure = mod.new CommunityStructure(graph);
        int[] comStructure = new int[graph.getNodeCount()];

        HashMap<String, Double> modularityValues = mod.computeModularity(graph, theStructure, comStructure,
                100., true, false);

        double modValue = modularityValues.get("modularity");
View Full Code Here

    }

    @Test
    public void testComputeBarbellGraphModularityHasHighWeight() {
        GraphModel graphModel = GraphGenerator.generateCompleteUndirectedGraph(4);
        UndirectedGraph undirectedGraph = graphModel.getUndirectedGraph();
        Node[] nodes = new Node[4];
        for (int i = 0; i < 4; i++) {
            Node currentNode = graphModel.factory().newNode(((Integer) (i + 4)).toString());
            nodes[i] = currentNode;
            undirectedGraph.addNode(currentNode);
        }
        for (int i = 0; i < 3; i++) {
            for (int j = i + 1; j < 4; j++) {
                Edge currentEdge = graphModel.factory().newEdge(nodes[i], nodes[j], false);
                undirectedGraph.addEdge(currentEdge);
            }
        }
        Edge currentEdge = graphModel.factory().newEdge(undirectedGraph.getNode("0"), undirectedGraph.getNode("5"), 0, 100.f, false);
        undirectedGraph.addEdge(currentEdge);
        UndirectedGraph graph = graphModel.getUndirectedGraph();

        Modularity mod = new Modularity();

        Modularity.CommunityStructure theStructure = mod.new CommunityStructure(graph);
        int[] comStructure = new int[graph.getNodeCount()];

        HashMap<String, Double> modularityValues = mod.computeModularity(graph, theStructure, comStructure,
                1., true, true);

        int class4 = comStructure[0];
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.