Package org.gephi.graph.api

Examples of org.gephi.graph.api.DirectedGraph


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

                    AbstractShortestPathAlgorithm algorithm;
                    if (gc.getGraphModel().isDirected()) {
                        DirectedGraph graph = gc.getGraphModel().getDirectedGraphVisible();
                        algorithm = new BellmanFordShortestPathAlgorithm(graph, n);
                        algorithm.compute();
                    } else {
                        Graph graph = gc.getGraphModel().getGraphVisible();
                        algorithm = new DijkstraShortestPathAlgorithm(graph, n);
View Full Code Here


        undirectedGraph.readLock();

        weaklyConnected(undirectedGraph, attributeModel);
        if (isDirected) {
            DirectedGraph directedGraph = graphModel.getDirectedGraphVisible();
            stronglyConnected(directedGraph, attributeModel);
        }

        undirectedGraph.readUnlock();
    }
View Full Code Here

    }

    public double calculateAverageWeightedDegree(Graph graph, boolean isDirected, boolean updateAttributes) {
        double averageWeightedDegree = 0;

        DirectedGraph directedGraph = null;

        if (isDirected) {
            directedGraph = (DirectedGraph) graph;
        }

        Progress.start(progress, graph.getNodeCount());

        for (Node n : graph.getNodes()) {
            double totalWeight = 0;
            if (isDirected) {
                double totalInWeight = 0;
                double totalOutWeight = 0;
                for (Edge e : directedGraph.getEdges(n)) {
                    if (e.getSource().equals(n)) {
                        totalOutWeight += e.getWeight();
                    }
                    if (e.getTarget().equals(n)) {
                        totalInWeight += e.getWeight();
View Full Code Here

    @Test
    public void testDirectedStarOutGraphPageRank() {
        pc.newProject();
        GraphModel graphModel = Lookup.getDefault().lookup(GraphController.class).getGraphModel();

        DirectedGraph directedGraph = graphModel.getDirectedGraph();
        Node firstNode = graphModel.factory().newNode("0");
        directedGraph.addNode(firstNode);
        for (int i = 1; i <= 5; i++) {
            Node currentNode = graphModel.factory().newNode(((Integer) i).toString());
            directedGraph.addNode(currentNode);
            Edge currentEdge = graphModel.factory().newEdge(firstNode, currentNode);
            directedGraph.addEdge(currentEdge);
        }

        DirectedGraph hgraph = graphModel.getDirectedGraph();
        PageRank pr = new PageRank();

        double[] pageRank;

        HashMap<Node, Integer> indicies = pr.createIndiciesMap(hgraph);

        pageRank = pr.calculatePagerank(hgraph, indicies, true, false, 0.001, 0.85);

        Node n1 = hgraph.getNode("0");
        Node n2 = hgraph.getNode("1");
        Node n3 = hgraph.getNode("2");
        Node n5 = hgraph.getNode("4");

        int index1 = indicies.get(n1);
        int index2 = indicies.get(n2);
        int index3 = indicies.get(n3);
        int index5 = indicies.get(n5);
View Full Code Here

    }

    protected double calculateAverageDegree(Graph graph, boolean isDirected, boolean updateAttributes) {
        double averageDegree = 0;

        DirectedGraph directedGraph = null;

        if (isDirected) {
            directedGraph = (DirectedGraph) graph;
        }
View Full Code Here

    @Test
    public void testPathDirectedGraphPageRank() {
        pc.newProject();
        GraphModel graphModel = GraphGenerator.generatePathDirectedGraph(4);
        DirectedGraph hgraph = graphModel.getDirectedGraph();

        PageRank pr = new PageRank();

        double[] pageRank;

        HashMap<Node, Integer> indicies = pr.createIndiciesMap(hgraph);

        pageRank = pr.calculatePagerank(hgraph, indicies, true, false, 0.001, 0.85);

        Node n1 = hgraph.getNode("0");
        Node n2 = hgraph.getNode("1");
        Node n3 = hgraph.getNode("2");
        Node n4 = hgraph.getNode("3");

        int index1 = indicies.get(n1);
        int index2 = indicies.get(n2);
        int index3 = indicies.get(n3);
        int index4 = indicies.get(n4);
View Full Code Here

    @Test
    public void testCyclicDirectedGraphPageRank() {
        pc.newProject();
        GraphModel graphModel = GraphGenerator.generateCyclicDirectedGraph(5);
        DirectedGraph hgraph = graphModel.getDirectedGraph();

        PageRank pr = new PageRank();

        double[] pageRank;

        HashMap<Node, Integer> indicies = pr.createIndiciesMap(hgraph);

        pageRank = pr.calculatePagerank(hgraph, indicies, true, false, 0.001, 0.85);

        Node n3 = hgraph.getNode("2");

        int index3 = indicies.get(n3);

        double pr3 = pageRank[index3];
        double res = 0.2d;
View Full Code Here

    @Test
    public void testDirectedSpecial1GraphPageRank() {
        pc.newProject();
        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");
        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");

        directedGraph.addNode(node1);
        directedGraph.addNode(node2);
        directedGraph.addNode(node3);
        directedGraph.addNode(node4);
        directedGraph.addNode(node5);
        directedGraph.addNode(node6);
        directedGraph.addNode(node7);
        directedGraph.addNode(node8);
        directedGraph.addNode(node9);

        Edge edge12 = graphModel.factory().newEdge(node1, node2);
        Edge edge23 = graphModel.factory().newEdge(node2, node3);
        Edge edge31 = graphModel.factory().newEdge(node3, node1);
        Edge edge14 = graphModel.factory().newEdge(node1, node4);
        Edge edge45 = graphModel.factory().newEdge(node4, node5);
        Edge edge51 = graphModel.factory().newEdge(node5, node1);
        Edge edge16 = graphModel.factory().newEdge(node1, node6);
        Edge edge67 = graphModel.factory().newEdge(node6, node7);
        Edge edge71 = graphModel.factory().newEdge(node7, node1);
        Edge edge18 = graphModel.factory().newEdge(node1, node8);
        Edge edge89 = graphModel.factory().newEdge(node8, node9);
        Edge edge91 = graphModel.factory().newEdge(node9, node1);

        directedGraph.addEdge(edge12);
        directedGraph.addEdge(edge23);
        directedGraph.addEdge(edge31);
        directedGraph.addEdge(edge14);
        directedGraph.addEdge(edge45);
        directedGraph.addEdge(edge51);
        directedGraph.addEdge(edge16);
        directedGraph.addEdge(edge67);
        directedGraph.addEdge(edge71);
        directedGraph.addEdge(edge18);
        directedGraph.addEdge(edge89);
        directedGraph.addEdge(edge91);

        DirectedGraph hgraph = graphModel.getDirectedGraph();
        PageRank pr = new PageRank();

        double[] pageRank;

        HashMap<Node, Integer> indicies = pr.createIndiciesMap(hgraph);
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.