Package org.gephi.graph.api

Examples of org.gephi.graph.api.Node


            }
        }
        for (Edge E : edges) {
            // Idem, pour tous les noeuds on applique la force d'attraction

            Node Nf = E.getSource();
            Node Nt = E.getTarget();

            float xDist = Nf.getNodeData().x() - Nt.getNodeData().x();
            float yDist = Nf.getNodeData().y() - Nt.getNodeData().y();
            float dist = (float) Math.sqrt(xDist * xDist + yDist * yDist);

            float attractiveF = dist * dist / k;

            if (dist > 0) {
                ForceVectorNodeLayoutData sourceLayoutData = Nf.getNodeData().getLayoutData();
                ForceVectorNodeLayoutData targetLayoutData = Nt.getNodeData().getLayoutData();
                sourceLayoutData.dx -= xDist / dist * attractiveF;
                sourceLayoutData.dy -= yDist / dist * attractiveF;
                targetLayoutData.dx += xDist / dist * attractiveF;
                targetLayoutData.dy += yDist / dist * attractiveF;
            }
View Full Code Here


            Modeler potInit = engine.getModelClasses()[AbstractEngine.CLASS_POTATO].getCurrentModeler();

            List<ModelImpl> hulls = new ArrayList<ModelImpl>();
            Node[] nodes = graph.getNodes().toArray();
            for (Node n : nodes) {
                Node parent = graph.getParent(n);
                if (parent != null) {
                    Group group = (Group) parent;
                    Model hullModel = group.getGroupData().getHullModel();
                    if (hullModel != null && hullModel.isCacheMatching(cacheMarker)) {
                        ConvexHull hull = (ConvexHull) hullModel.getObj();
View Full Code Here

                switch (type) {
                    case XMLStreamReader.START_ELEMENT:
                        String name = reader.getLocalName();
                        if (ELEMENT_NODEDATA_TEXTDATA.equalsIgnoreCase(name)) {
                            int id = Integer.parseInt(reader.getAttributeValue(null, "for"));
                            Node node = hierarchicalGraph.getNode(id);
                            TextDataImpl textDataImpl = (TextDataImpl) node.getNodeData().getTextData();
                            readTextData(reader, textDataImpl);
                        } else if (ELEMENT_EDGEDATA_TEXTDATA.equalsIgnoreCase(name)) {
                            int id = Integer.parseInt(reader.getAttributeValue(null, "for"));
                            Edge edge = hierarchicalGraph.getEdge(id);
                            TextDataImpl textDataImpl = (TextDataImpl) edge.getEdgeData().getTextData();
View Full Code Here

            if (node.getNodeData().getLabel() != null && !node.getNodeData().getLabel().isEmpty()) {
                xmlWriter.writeAttribute(NODE_LABEL, node.getNodeData().getLabel());
            }

            if (exportHierarchy) {
                Node parent = graph.getParent(node);
                if (parent != null) {
                    xmlWriter.writeAttribute(NODE_PID, parent.getNodeData().getId());
                }
            }

            if (exportDynamic && dynamicCol != null && visibleInterval != null) {
                TimeInterval timeInterval = (TimeInterval) node.getNodeData().getAttributes().getValue(dynamicCol.getIndex());
View Full Code Here

* @author Helder Suzuki <heldersuzuki@gephi.org>
*/
public class GraphUtils {

    public static Node getTopmostParent(HierarchicalGraph graph, Node n) {
        Node parent = graph.getParent(n);
        while (parent != null) {
            n = parent;
            parent = graph.getParent(n);
        }
        return n;
View Full Code Here

        AttributeModel attributeModel = attributeController.getModel();
        GraphController graphController = Lookup.getDefault().lookup(GraphController.class);
        GraphModel graphModel = graphController.getModel();
        HierarchicalDirectedGraph graph = graphModel.getHierarchicalDirectedGraph();

        Node n1 = graphModel.factory().newNode("n1");
        graph.addNode(n1);
        Node n2 = graphModel.factory().newNode("n2");
        graph.addNode(n2);
        Node n3 = graphModel.factory().newNode("n3");
        graph.addNode(n3);
        Node n4 = graphModel.factory().newNode("n4");
        graph.addNode(n4, n3);

        Edge e1 = graphModel.factory().newEdge(n1, n2, 1f, true);
        graph.addEdge(e1);
        Edge e2 = graphModel.factory().newEdge(n2, n4, 3f, true);
View Full Code Here

        GraphController graphController = Lookup.getDefault().lookup(GraphController.class);
        graphModel = graphController.getModel();
        DirectedGraph graph = graphModel.getDirectedGraph();

        for (int i = 0; i < NODES; i++) {
            Node newNode = graphModel.factory().newNode();
            graph.addNode(newNode);
        }

        Random random = new Random();
        int j = 0;
        while (j < EDGES) {
            Node source = graph.getNode(random.nextInt(NODES));
            Node target = graph.getNode(random.nextInt(NODES));
            if (graph.getEdge(source, target) == null) {
                graph.addEdge(graphModel.factory().newEdge(source, target));
                j++;
            }
        }
View Full Code Here

        }
        // attraction
        if (isAdjustSizes()) {
            if (isOutboundAttractionDistribution()) {
                for (Edge e : edges) {
                    Node nf = e.getSource();
                    Node nt = e.getTarget();
                    double bonus = (nf.getNodeData().isFixed() || nt.getNodeData().isFixed()) ? (100) : (1);
                    bonus *= getWeight(e);
                    ForceVectorUtils.fcBiAttractor_noCollide(nf.getNodeData(), nt.getNodeData(), bonus * getAttractionStrength() / (1 + graph.getDegree(nf)));
                }
            } else {
                for (Edge e : edges) {
                    Node nf = e.getSource();
                    Node nt = e.getTarget();
                    double bonus = (nf.getNodeData().isFixed() || nt.getNodeData().isFixed()) ? (100) : (1);
                    bonus *= getWeight(e);
                    ForceVectorUtils.fcBiAttractor_noCollide(nf.getNodeData(), nt.getNodeData(), bonus * getAttractionStrength());
                }
            }
        } else {
            if (isOutboundAttractionDistribution()) {
                for (Edge e : edges) {
                    Node nf = e.getSource();
                    Node nt = e.getTarget();
                    double bonus = (nf.getNodeData().isFixed() || nt.getNodeData().isFixed()) ? (100) : (1);
                    bonus *= getWeight(e);
                    ForceVectorUtils.fcBiAttractor(nf.getNodeData(), nt.getNodeData(), bonus * getAttractionStrength() / (1 + graph.getDegree(nf)));
                }
            } else {
                for (Edge e : edges) {
                    Node nf = e.getSource();
                    Node nt = e.getTarget();
                    double bonus = (nf.getNodeData().isFixed() || nt.getNodeData().isFixed()) ? (100) : (1);
                    bonus *= getWeight(e);
                    ForceVectorUtils.fcBiAttractor(nf.getNodeData(), nt.getNodeData(), bonus * getAttractionStrength());
                }
            }
        }
        // gravity
        for (Node n : nodes) {
View Full Code Here

    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

            GraphView hgraphView = hgraph.getView();
            HierarchicalGraph mainHGraph = hgraph.getView().getGraphModel().getHierarchicalGraph();

            List<Edge> edgesToKeep = new ArrayList<Edge>();
            for (Edge e : mainHGraph.getEdges().toArray()) {
                Node source = e.getSource().getNodeData().getNode(hgraphView.getViewId());
                Node target = e.getTarget().getNodeData().getNode(hgraphView.getViewId());
                boolean keep = false;
                switch (option) {
                    case SOURCE:
                        keep = source != null;
                        break;
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.