Package org.gephi.graph.api

Examples of org.gephi.graph.api.Node


        //Load matrix
        SparseMatrix matrix = new SparseMatrix();
        int nodeId = 0;
        for (Edge e : graph.getEdges()) {
            Node source = e.getSource();
            Node target = e.getTarget();
            Integer sourceId;
            Integer targetId;
            if ((sourceId = intMap.get(source)) == null) {
                sourceId = nodeId++;
                intMap.put(source, sourceId);
                nodeMap.put(sourceId, source);
            }
            if ((targetId = intMap.get(target)) == null) {
                targetId = nodeId++;
                intMap.put(target, targetId);
                nodeMap.put(targetId, target);
            }
            double weight = e.getWeight();
            matrix.add(sourceId, targetId, weight);

            if (cancelled) {
                graph.readUnlockAll();
                return;
            }
        }

        graph.readUnlock();

        matrix = matrix.transpose();
        matrix = run(matrix, maxResidual, gammaExp, loopGain, zeroMax);

        if (cancelled) {
            return;
        }

        Map<Integer, ArrayList<Integer>> map = getClusters(matrix);

        if (cancelled) {
            return;
        }

        int clusterNumber = 1;
        List<Cluster> clustersList = new ArrayList<Cluster>();
        Set<ArrayList<Integer>> sortedClusters = new HashSet<ArrayList<Integer>>();
        for (ArrayList<Integer> c : map.values()) {
            if (!sortedClusters.contains(c)) {
                sortedClusters.add(c);
                Node[] nodes = new Node[c.size()];
                int i = 0;
                for (Integer in : c) {
                    Node node = nodeMap.get(in);
                    nodes[i] = node;
                    i++;
                }
                clustersList.add(new MCLCluster(nodes, clusterNumber));
                clusterNumber++;
View Full Code Here


    }

    private ModelImpl[] computeHull() {
        Iterator<Node> itr = groupNodesTree.iterator();
        for (; itr.hasNext();) {
            Node n = itr.next();
            if (n.getNodeData().getModel() == null) {
                itr.remove();
            } else if (model != null && !n.getNodeData().getModel().isCacheMatching(model.getCacheMarker())) {
                itr.remove();
            }
        }
        Node[] n = AlgoHull.calculate(groupNodesTree.toArray(new Node[0]));
        ModelImpl[] models = new ModelImpl[n.length];
View Full Code Here

    public void execute() {
        try {
            Set<Node> parents = new HashSet<Node>();
            for (Node node : nodes) {
                Node nodeParent = graph.getParent(node);
                if (nodeParent != null) {
                    parents.add(nodeParent);
                }
            }
View Full Code Here

        GraphFactoryImpl factory = dhnsGlobal.factory();

        //Nodes
        //System.out.println("-----Global-----");
        for (int i = 0; i < 10; i++) {
            Node node = factory.newNode();
            node.getNodeData().setLabel("Node " + i);
            graphGlobal.addNode(node);
            nodeMap.put(node.getNodeData().getLabel(), node);
            //System.out.println("Node " + i + " added. Id = " + node.getId());
        }
        //System.out.println("---End Global---");

        //Edges
        Node node0 = nodeMap.get("Node 0");
        Node node1 = nodeMap.get("Node 1");
        Node node2 = nodeMap.get("Node 2");
        Node node3 = nodeMap.get("Node 3");
        Node node4 = nodeMap.get("Node 4");
        Node node5 = nodeMap.get("Node 5");
        Node node6 = nodeMap.get("Node 6");
        Node node7 = nodeMap.get("Node 7");
        Node node8 = nodeMap.get("Node 8");

        AbstractEdge edge1 = factory.newEdge("4-5", node4, node5, 1f, true);
        AbstractEdge edge2 = factory.newEdge("5-6", node5, node6, 4f, true);
        AbstractEdge edge3 = factory.newEdge("6-5", node6, node5, 3f, true);
        AbstractEdge edge4 = factory.newEdge("7-7", node7, node7, 5f, true);
View Full Code Here

        }
    }

    @Test
    public void testDelete() {
        Node node1 = nodeMap.get("Node 1");
        Node node2 = nodeMap.get("Node 2");
        Edge edge21 = edgeMap.get("2-1");

        GraphView newView = dhnsGlobal.newView();
        HierarchicalGraph viewGraph = dhnsGlobal.getHierarchicalGraph(newView);
View Full Code Here

    public boolean isGroupable(Partition partition) {
        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;
                }
View Full Code Here

    public boolean isUngroupable(Partition partition) {
        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;
                }
View Full Code Here

                    r += n.getNodeData().r();
                    g += n.getNodeData().g();
                    b += n.getNodeData().b();
                    len++;
                }
                Node metaNode = graph.groupNodes(validNodes.toArray(new Node[0]));
                metaNode.getNodeData().setX(centroidX / len);
                metaNode.getNodeData().setY(centroidY / len);
                metaNode.getNodeData().setLabel(p.getDisplayName());
                metaNode.getNodeData().setSize(sizes / graph.getNodeCount() * 5f);
                metaNode.getNodeData().setColor(r / len, g / len, b / len);
            }
        }
    }
View Full Code Here

                if (graph.contains(n)) {
                    validNodes.add(n);
                }
            }
            if (!validNodes.isEmpty()) {
                Node metaNode = graph.getParent(validNodes.get(0));
                if (metaNode != null) {
                    graph.ungroupNodes(metaNode);
                }
            }
        }
View Full Code Here

        this.graph = graphModel.getHierarchicalGraphVisible();
        ModelImpl[] selectedNodeModels = engine.getSelectedObjects(AbstractEngine.CLASS_NODE);
        ArrayList<Node> nodes=new ArrayList<Node>();
        for (ModelImpl metaModelImpl : selectedNodeModels) {
            NodeData nodeData = (NodeData) metaModelImpl.getObj();
            Node node = nodeData.getNode(graph.getView().getViewId());
            if (node != null) {
                nodes.add(node);
            }
        }
        return nodes.toArray(new Node[0]);
View Full Code Here

TOP

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

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.