Package org.gephi.graph.api

Examples of org.gephi.graph.api.HierarchicalGraph


                rankingList.add(outDegreeRanking);
            }
        }

        if (model.isHierarchical()) {
            HierarchicalGraph hierarchicalGraph = model.getHierarchicalGraphVisible();
            NodeRanking childrenRanking = RankingFactory.getNodeChildrenCountRanking(hierarchicalGraph);
            if (childrenRanking.getMinimumValue() != null && childrenRanking.getMaximumValue() != null && !childrenRanking.getMinimumValue().equals(childrenRanking.getMaximumValue())) {
                rankingList.add(childrenRanking);
            }
        }
View Full Code Here


* @author Helder Suzuki <heldersuzuki@gephi.org>
*/
public class MaximalMatchingCoarsening implements MultiLevelLayout.CoarseningStrategy {

    public void coarsen(HierarchicalGraph g) {
        HierarchicalGraph graph = g;
        int retract = 0;
        int count = 0;
        for (Edge e : graph.getEdgesAndMetaEdges().toArray()) {
            Node a = e.getSource();
            Node b = e.getTarget();
            count++;
            if (graph.getParent(a) == graph.getParent(b) && graph.getLevel(a) == 0) {
                float x = (a.getNodeData().x() + b.getNodeData().x()) / 2;
                float y = (a.getNodeData().y() + b.getNodeData().y()) / 2;

                Node parent = graph.groupNodes(new Node[]{a, b});
                parent.getNodeData().setX(x);
                parent.getNodeData().setY(y);
                graph.retract(parent);
                retract++;
            }
        }
    }
View Full Code Here

        if (partition instanceof NodePartition) {
            if (partition.getPartsCount() > 0) {
                NodePartition nodePartition = (NodePartition) partition;
                Node n0 = nodePartition.getParts()[0].getObjects()[0];
                GraphModel graphModel = Lookup.getDefault().lookup(GraphController.class).getModel();
                HierarchicalGraph graph = graphModel.getHierarchicalGraphVisible();
                if (graph.contains(n0) && graph.getParent(n0) == null) {
                    return true;
                }
            }
        }
        return false;
View Full Code Here

        if (partition instanceof NodePartition) {
            if (partition.getPartsCount() > 0) {
                NodePartition nodePartition = (NodePartition) partition;
                Node n0 = nodePartition.getParts()[0].getObjects()[0];
                GraphModel graphModel = Lookup.getDefault().lookup(GraphController.class).getModel();
                HierarchicalGraph graph = graphModel.getHierarchicalGraphVisible();
                if (graph.contains(n0) && graph.getParent(n0) != null) {
                    return true;
                }
            }
        }
        return false;
View Full Code Here

        public Graph filter(Graph graph, Filter[] filters) {
            if (filters.length > 1) {
                throw new IllegalArgumentException("Filter accepts a single filter in parameter");
            }
            HierarchicalGraph hgraph = (HierarchicalGraph) graph;
            if (filters[0] instanceof NodeFilter && ((NodeFilter) filters[0]).init(hgraph)) {
                NodeFilter filter = (NodeFilter) filters[0];
                GraphView hgraphView = hgraph.getView();
                for (Edge e : hgraph.getEdges().toArray()) {
                    Node source = e.getSource().getNodeData().getNode(hgraphView.getViewId());
                    Node target = e.getTarget().getNodeData().getNode(hgraphView.getViewId());
                    boolean remove = false;
                    switch (option) {
                        case SOURCE:
                            remove = !filter.evaluate(hgraph, source);
                            break;
                        case TARGET:
                            remove = !filter.evaluate(hgraph, target);
                            break;
                        case BOTH:
                            remove = !filter.evaluate(hgraph, source) || !filter.evaluate(hgraph, target);
                            break;
                        case ANY:
                            remove = !filter.evaluate(hgraph, source) && !filter.evaluate(hgraph, target);
                            break;
                    }
                    if (remove) {
                        hgraph.removeEdge(e);
                    }
                }
                filter.finish();
            }
            return hgraph;
View Full Code Here

    }

    private class RefreshRunnable implements Runnable {

        public void run() {
            HierarchicalGraph visibleGraph = model.getHierarchicalGraphVisible();
            HierarchicalGraph fullGraph = model.getHierarchicalGraph();
            final int nodesFull = fullGraph.getNodeCount();
            final int nodesVisible = visibleGraph.getNodeCount();
            final int edgesFull = fullGraph.getTotalEdgeCount();
            final int edgesVisible = visibleGraph.getTotalEdgeCount();
            final GraphType graphType = visibleGraph instanceof DirectedGraph ? GraphType.DIRECTED : visibleGraph instanceof UndirectedGraph ? GraphType.UNDIRECTED : GraphType.MIXED;
            SwingUtilities.invokeLater(new Runnable() {

                public void run() {
View Full Code Here

        public Graph filter(Graph[] graphs) {
            if (graphs.length > 1) {
                throw new IllegalArgumentException("Not Filter accepts a single graph in parameter");
            }

            HierarchicalGraph hgraph = (HierarchicalGraph) graphs[0];
            GraphView hgraphView = hgraph.getView();
            HierarchicalGraph mainHGraph = hgraph.getView().getGraphModel().getHierarchicalGraph();
            for (Edge e : mainHGraph.getEdges().toArray()) {
                Node source = e.getSource().getNodeData().getNode(hgraphView.getViewId());
                Node target = e.getTarget().getNodeData().getNode(hgraphView.getViewId());
                if (source != null && target != null) {
                    Edge edgeInGraph = hgraph.getEdge(source, target);
                    if (edgeInGraph == null) {
View Full Code Here

        public Graph filter(Graph graph, Filter[] filters) {
            if (filters.length > 1) {
                throw new IllegalArgumentException("Not Filter accepts a single filter in parameter");
            }
            HierarchicalGraph hgraph = (HierarchicalGraph) graph;
            Filter filter = filters[0];
            if (filter instanceof EdgeFilter && ((EdgeFilter) filter).init(hgraph)) {
                EdgeFilter edgeFilter = (EdgeFilter) filter;
                for (Edge e : hgraph.getEdgesAndMetaEdges().toArray()) {
                    if (edgeFilter.evaluate(hgraph, e)) {
                        hgraph.removeEdge(e);
                    }
                }
                edgeFilter.finish();
            }
View Full Code Here

    }

    public void groupCluster(Cluster cluster) {
        GraphModel gm = Lookup.getDefault().lookup(GraphController.class).getModel();
        if (gm != null) {
            HierarchicalGraph graph = gm.getHierarchicalGraphVisible();
            Node[] newGroup = cluster.getNodes();
            float centroidX = 0;
            float centroidY = 0;
            int len = 0;
            Node group = graph.groupNodes(newGroup);
            cluster.setMetaNode(group);

            group.getNodeData().setLabel("Group");
            group.getNodeData().setSize(10f);
            for (Node child : newGroup) {
View Full Code Here

    }

    public void ungroupCluster(Cluster cluster) {
        GraphModel gm = Lookup.getDefault().lookup(GraphController.class).getModel();
        if (gm != null) {
            HierarchicalGraph graph = gm.getHierarchicalGraphVisible();
            graph.ungroupNodes(cluster.getMetaNode());
            cluster.setMetaNode(null);
        }
    }
View Full Code Here

TOP

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

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.