Package org.gephi.graph.api

Examples of org.gephi.graph.api.HierarchicalGraph


        public boolean init(Graph graph) {
            return true;
        }

        public Graph filter(Graph graph) {
            HierarchicalGraph hierarchicalGraph = (HierarchicalGraph) graph;
            hierarchicalGraph.flatten();
            return hierarchicalGraph;
        }
View Full Code Here


        private Integer level = 0;
        private int height;

        public boolean init(Graph graph) {
            HierarchicalGraph hg = (HierarchicalGraph) graph;
            height = hg.getHeight();
            return true;
        }
View Full Code Here

            height = hg.getHeight();
            return true;
        }

        public boolean evaluate(Graph graph, Node node) {
            HierarchicalGraph hg = (HierarchicalGraph) graph;
            return hg.getLevel(node) == level.intValue();
        }
View Full Code Here

        public String getName() {
            return NbBundle.getMessage(AttributeEqualBuilder.class, "AttributeNonNullBuilder.name");
        }

        public boolean init(Graph graph) {
            HierarchicalGraph hg = (HierarchicalGraph)graph;
            if (AttributeUtils.getDefault().isNodeColumn(column)) {
                if (graph.getNodeCount() == 0) {
                    return false;
                }
            } else if (AttributeUtils.getDefault().isEdgeColumn(column)) {
                if (hg.getTotalEdgeCount() == 0) {
                    return false;
                }
            }
            return true;
        }
View Full Code Here

        private int depth = 1;

        public Graph filter(Graph graph) {

            GraphView graphView = graph.getView();
            HierarchicalGraph mainGraph = graphView.getGraphModel().getHierarchicalGraph();

            List<Node> nodes = new ArrayList<Node>();
            for (Node n : graph.getNodes()) {
                nodes.add(n.getNodeData().getNode(mainGraph.getView().getViewId()));
            }

            Set<Node> result = new HashSet<Node>();

            Set<Node> neighbours = new HashSet<Node>();
            neighbours.addAll(nodes);

            //Put all neighbors into result
            for (int i = 0; i < depth; i++) {
                Node[] nei = neighbours.toArray(new Node[0]);
                neighbours.clear();
                for (Node n : nei) {
                    //Extract all neighbors of n
                    for (Node neighbor : mainGraph.getNeighbors(n)) {
                        if (!result.contains(neighbor)) {
                            neighbours.add(neighbor);
                            result.add(neighbor);
                        }
                    }
                }
                if (neighbours.isEmpty()) {
                    break;
                }
            }

            if (self) {
                result.addAll(nodes);
            } else {
                result.removeAll(nodes);
            }

            //Update nodes
            for (Node node : mainGraph.getNodes().toArray()) {
                if (result.contains(node)) {
                    graph.addNode(node);
                } else if(graph.contains(node)) {
                    graph.removeNode(node);
                }
            }

            //Update edges
            for (Node n : graph.getNodes().toArray()) {
                Node mainNode = n.getNodeData().getNode(mainGraph.getView().getViewId());
                Edge[] edges = mainGraph.getEdges(mainNode).toArray();
                for (Edge e : edges) {
                    if (e.getSource().getNodeData().getNode(graphView.getViewId()) != null
                            && e.getTarget().getNodeData().getNode(graphView.getViewId()) != null) {
                        graph.addEdge(e);
                    }
View Full Code Here

        public String getName() {
            return column.getTitle() + " " + NbBundle.getMessage(AttributeRangeBuilder.class, "AttributeRangeBuilder.name");
        }

        public boolean init(Graph graph) {
            HierarchicalGraph hg = (HierarchicalGraph) graph;
            if (AttributeUtils.getDefault().isNodeColumn(column)) {
                if (graph.getNodeCount() == 0) {
                    return false;
                }
            } else if (AttributeUtils.getDefault().isEdgeColumn(column)) {
                if (hg.getTotalEdgeCount() == 0) {
                    return false;
                }
            }
            dynamicHelper = new DynamicAttributesHelper(this, hg);
            refreshValues(hg);
View Full Code Here

        public PartitionCountFilter(Partition partition) {
            this.partition = partition;
        }

        public boolean init(Graph graph) {
            HierarchicalGraph hg = (HierarchicalGraph) graph;
            this.partition = Lookup.getDefault().lookup(PartitionController.class).buildPartition(partition.getColumn(), hg);
            if (partition.getParts().length > 0) {
                refreshValues(graph);
                return true;
            }
View Full Code Here

    public double getDensity() {
        return density;
    }

    public void execute(GraphModel graphModel, AttributeModel attributeModel) {
        HierarchicalGraph hgraph;

        if (isDirected) {
            hgraph = graphModel.getHierarchicalDirectedGraphVisible();
        } else {
            hgraph = graphModel.getHierarchicalUndirectedGraphVisible();
        }

        double edgesCount = hgraph.getTotalEdgeCount();
        double nodesCount = hgraph.getNodeCount();
        double multiplier = 1;

        if (!isDirected) {
            multiplier = 2;
        }
View Full Code Here

        public String getName() {
            return NbBundle.getMessage(PartitionBuilder.class, "PartitionBuilder.name");
        }

        public boolean init(Graph graph) {
            HierarchicalGraph hg = (HierarchicalGraph)graph;
            this.partition = Lookup.getDefault().lookup(PartitionController.class).buildPartition(partition.getColumn(), hg);
            return true;
        }
View Full Code Here

        public FilterProperty[] getProperties() {
            return null;
        }

        public Graph filter(Graph[] graphs) {
            HierarchicalGraph minHGraph = (HierarchicalGraph) graphs[0];
            int minElements = Integer.MAX_VALUE;
            for (int i = 0; i < graphs.length; i++) {
                int count = ((HierarchicalGraph)graphs[i]).getNodeCount();
                if (count < minElements) {
                    minHGraph = (HierarchicalGraph) graphs[i];
                    minElements = count;
                }
            }
            for (Node n : minHGraph.getNodes().toArray()) {
                for (int i = 0; i < graphs.length; i++) {
                    if ((HierarchicalGraph)graphs[i] != minHGraph) {
                        if (!((HierarchicalGraph)graphs[i]).contains(n)) {
                            minHGraph.removeNode(n);
                            break;
                        }
                    }
                }
            }
            for (Edge e : minHGraph.getEdges().toArray()) {
                for (int i = 0; i < graphs.length; i++) {
                    if ((HierarchicalGraph)graphs[i] != minHGraph) {
                        if (!((HierarchicalGraph)graphs[i]).contains(e)) {
                            minHGraph.removeEdge(e);
                            break;
                        }
                    }
                }
            }
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.