Package org.gephi.graph.api

Examples of org.gephi.graph.api.Graph


        return getSnapshotGraph(new Interval(low, high), Estimator.FIRST);
    }

    @Override
    public Graph getSnapshotGraph(Interval interval, Estimator estimator) {
        Graph graph = model.getGraph(sourceView);
        Graph vgraph = model.getGraph(currentView);

        graph.writeLock();

        if (attributeModel.getNodeTable().hasColumn(DynamicModel.TIMEINTERVAL_COLUMN)) {
            for (Node n : graph.getNodes().toArray()) {
                TimeInterval ti = (TimeInterval) n.getNodeData().getAttributes().getValue(DynamicModel.TIMEINTERVAL_COLUMN);
                if (ti == null && !vgraph.contains(n)) {
                    vgraph.addNode(n);
                } else if (ti != null) {
                    boolean isInRange = ti.isInRange(interval);
                    boolean isInGraph = vgraph.contains(n);
                    if (!isInRange && isInGraph) {
                        vgraph.removeNode(n);
                    } else if (isInRange && !isInGraph) {
                        vgraph.addNode(n);
                    }
                }
            }
        }
        if (attributeModel.getEdgeTable().hasColumn(DynamicModel.TIMEINTERVAL_COLUMN)) {
            for (Edge e : graph.getEdges().toArray()) {
                TimeInterval ti = (TimeInterval) e.getEdgeData().getAttributes().getValue(DynamicModel.TIMEINTERVAL_COLUMN);
                if (ti == null && !vgraph.contains(e)
                        && vgraph.contains(e.getSource()) && vgraph.contains(e.getTarget())) {
                    vgraph.addEdge(e);
                } else if (ti != null) {
                    boolean isInRange = ti.isInRange(interval);
                    boolean isInGraph = vgraph.contains(e);
                    if (!isInRange && isInGraph) {
                        vgraph.removeEdge(e);
                    } else if (isInRange && !isInGraph && vgraph.contains(e.getSource()) && vgraph.contains(e.getTarget())) {
                        vgraph.addEdge(e);
                    }
                }
            }
        }
        graph.writeUnlock();
View Full Code Here


        return getStrongSnapshotGraph(new Interval(low, high));
    }

    @Override
    public Graph getStrongSnapshotGraph(Interval interval) {
        Graph graph = model.getGraph(sourceView);
        Graph vgraph = model.getGraph(currentView);
        for (Node n : graph.getNodes().toArray()) {
            TimeInterval ti = (TimeInterval) n.getNodeData().getAttributes().getValue(DynamicModel.TIMEINTERVAL_COLUMN);
            if (ti.getValues(interval).size() < ti.getValues().size() && vgraph.contains(n)) {
                vgraph.removeNode(n);
            } else if (ti.getValues(interval).size() == ti.getValues().size() && !vgraph.contains(n)) {
                vgraph.addNode(n);
            }
        }
        for (Edge e : graph.getEdges().toArray()) {
            TimeInterval ti = (TimeInterval) e.getEdgeData().getAttributes().getValue(DynamicModel.TIMEINTERVAL_COLUMN);
            if (ti.getValues(interval).size() < ti.getValues().size() && vgraph.contains(e)) {
                vgraph.removeEdge(e);
            } else if (ti.getValues(interval).size() == ti.getValues().size() && !vgraph.contains(e)
                    && vgraph.contains(e.getSource()) && vgraph.contains(e.getTarget())) {
                vgraph.addEdge(e);
            }
        }
        return vgraph;
    }
View Full Code Here

        return report;
    }

    @Override
    public void loop(GraphView window, Interval interval) {
        Graph graph = graphModel.getGraph(window);
        DirectedGraph directedGraph = null;
        if (isDirected) {
            directedGraph = graphModel.getDirectedGraph(window);
        }

        long sum = 0;
        for (Node n : graph.getNodes().toArray()) {
            int degree = graph.getDegree(n);

            if (!averageOnly) {
                n.setAttribute(dynamicDegreeColumn, degree, interval.getLow());

                if (isDirected) {
                    int indegree = directedGraph.getInDegree(n);
                    n.setAttribute(dynamicInDegreeColumn, indegree, interval.getLow());

                    int outdegree = directedGraph.getOutDegree(n);
                    n.setAttribute(dynamicOutDegreeColumn, outdegree, interval.getLow());
                }
            }
            sum += degree;
            if (cancel) {
                break;
            }
        }

        double avg = sum / (double) graph.getNodeCount();
        averages.put(interval.getLow(), avg);
        averages.put(interval.getHigh(), avg);
       
        graph.setAttribute(DYNAMIC_AVGDEGREE, avg, interval.getLow());
        graph.setAttribute(DYNAMIC_AVGDEGREE, avg, interval.getHigh());
    }
View Full Code Here

        return report;
    }

    @Override
    public void loop(GraphView window, Interval interval) {
        Graph graph = graphModel.getGraph(window);

        int count = graph.getEdgeCount();
       
        graph.setAttribute(NB_EDGES, count, interval.getLow());
        graph.setAttribute(NB_EDGES, count, interval.getHigh());

        counts.put(interval.getLow(), count);
        counts.put(interval.getHigh(), count);
    }
View Full Code Here

    }

    @Test
    public void testOneNodeHits() {
        GraphModel graphModel = GraphGenerator.generateNullUndirectedGraph(1);
        Graph hgraph = graphModel.getUndirectedGraph();

        Hits hit = new Hits();

        double[] authority = new double[1];
        double[] hubs = new double[1];

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

        hit.calculateHits(hgraph, hubs, authority, indicies, false, 0.01);

        Node n1 = hgraph.getNode("0");
        int index = indicies.get(n1);
        double hub1 = hubs[index];
        double auth1 = authority[index];

        assertEquals(hub1, 1.0);
View Full Code Here

    }

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

        Hits hit = new Hits();

        double[] authority = new double[2];
        double[] hubs = new double[2];

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

        hit.calculateHits(hgraph, hubs, authority, indicies, false, 0.01);

        Node n1 = hgraph.getNode("0");
        Node n2 = hgraph.getNode("1");
        int index1 = indicies.get(n1);
        int index2 = indicies.get(n2);
        double hub1 = hubs[index1];
        double auth2 = authority[index2];
View Full Code Here

    }

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

        Hits hit = new Hits();

        double[] authority = new double[5];
        double[] hubs = new double[5];

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

        hit.calculateHits(hgraph, hubs, authority,indicies, false, 0.01);

        Node n2 = hgraph.getNode("1");
        Node n3 = hgraph.getNode("2");
        int index2 = indicies.get(n2);
        int index3 = indicies.get(n3);
        double hub2 = hubs[index2];
        double auth3 = authority[index3];
View Full Code Here

    }

    @Test
    public void testCompleteGraphHits() {
        GraphModel graphModel = GraphGenerator.generateCompleteUndirectedGraph(5);
        Graph hgraph = graphModel.getUndirectedGraph();

        Hits hit = new Hits();

        double[] authority = new double[5];
        double[] hubs = new double[5];

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

        hit.calculateHits(hgraph, hubs, authority, indicies, false, 0.01);

        Node n1 = hgraph.getNode("0");
        Node n5 = hgraph.getNode("4");
        int index1 = indicies.get(n1);
        int index5 = indicies.get(n5);
        double hub1 = hubs[index1];
        double auth5 = authority[index5];
View Full Code Here

    }

    @Test
    public void testStarGraphHits() {
        GraphModel graphModel = GraphGenerator.generateStarUndirectedGraph(5);
        Graph hgraph = graphModel.getUndirectedGraph();

        Hits hit = new Hits();

        double[] authority = new double[6];
        double[] hubs = new double[6];

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

        hit.calculateHits(hgraph, hubs, authority, indicies, false, 0.01);

        Node n1 = hgraph.getNode("0");
        Node n3 = hgraph.getNode("2");
        Node n4 = hgraph.getNode("3");
        int index1 = indicies.get(n1);
        int index3 = indicies.get(n3);
        int index4 = indicies.get(n4);

        double hub1 = hubs[index1];
View Full Code Here

        undirectedGraph.addEdge(edge12);
        undirectedGraph.addEdge(edge23);
        undirectedGraph.addEdge(edge11);
        undirectedGraph.addEdge(edge33);

        Graph hgraph = graphModel.getUndirectedGraph();

        Hits hit = new Hits();

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

        double[] authority = new double[3];
        double[] hubs = new double[3];

        hit.calculateHits(hgraph, hubs, authority, indicies, false, 0.01);

        Node n1 = hgraph.getNode("0");
        Node n2 = hgraph.getNode("1");
        int index1 = indicies.get(n1);
        int index2 = indicies.get(n2);

        double hub1 = hubs[index1];
        double hub2 = hubs[index2];
View Full Code Here

TOP

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

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.