Package org.gephi.graph.api

Examples of org.gephi.graph.api.Node


            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;
View Full Code Here


        dhns2 = new Dhns(controller2, workspace2);
        graph2 = new HierarchicalDirectedGraphImpl(dhns2, dhns2.getGraphStructure().getMainView());
        GraphFactoryImpl factory2 = dhns2.factory();

        for (int i = 0; i < 10; i++) {
            Node node = factory2.newNode();
            node.getNodeData().setLabel("Node " + i);
            graph2.addNode(node);
            nodeMap2.put(node.getNodeData().getLabel(), node);
        }
        Node node4 = nodeMap2.get("Node 4");
        Node node5 = nodeMap2.get("Node 5");
        Node node6 = nodeMap2.get("Node 6");
        Node node7 = nodeMap2.get("Node 7");

        AbstractEdge edge1 = factory2.newEdge(node4, node5);
        AbstractEdge edge2 = factory2.newEdge(node5, node6);
        AbstractEdge edge3 = factory2.newEdge(node6, node5);
        AbstractEdge edge4 = factory2.newEdge(node7, node7);
View Full Code Here

            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) {
                        //The edge is not in graph
                        hgraph.addEdge(e);
View Full Code Here

                for (Node neighbor : hgraph.getNeighbors(node)) {
                    neighborTable.put(neighbor, new EdgeWrapper(1, network[indicies.get(neighbor)]));
                }
            } else {
                for (Edge in : ((HierarchicalDirectedGraph) hgraph).getInEdgesAndMetaInEdges(node)) {
                    Node neighbor = in.getSource();
                    neighborTable.put(neighbor, new EdgeWrapper(1, network[indicies.get(neighbor)]));
                }

                for (Edge out : ((HierarchicalDirectedGraph) hgraph).getOutEdgesAndMetaOutEdges(node)) {
                    Node neighbor = out.getTarget();
                    EdgeWrapper ew = neighborTable.get(neighbor);
                    if (ew == null) {
                        neighborTable.put(neighbor, new EdgeWrapper(1, network[indicies.get(neighbor)]));
                    } else {
                        ew.count++;
View Full Code Here

            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) {
                centroidX += child.getNodeData().x();
                centroidY += child.getNodeData().y();
                len++;
            }
            centroidX /= len;
            centroidY /= len;
            group.getNodeData().setX(centroidX);
            group.getNodeData().setY(centroidY);
        }
    }
View Full Code Here

    @Test
    public void testNodeDefaultId() {
        GraphFactory factory = graphModel.factory();

        Node n1 = factory.newNode();
        rootGraph.addNode(n1);

        String n1Id = "" + n1.getId();
        assertEquals(n1Id, n1.getNodeData().getId());
        assertEquals(n1, rootGraph.getNode(n1Id));
    }
View Full Code Here

    @Test
    public void testEdgeDefaultId() {
        GraphFactory factory = graphModel.factory();

        Node n1 = factory.newNode();
        Node n2 = factory.newNode();
        rootGraph.addNode(n1);
        rootGraph.addNode(n2);

        Edge e1 = factory.newEdge(n1, n2);
        rootGraph.addEdge(e1);
View Full Code Here

    @Test
    public void testSetId() {
        GraphFactory factory = graphModel.factory();

        Node n1 = factory.newNode();
        Node n2 = factory.newNode();
        rootGraph.addNode(n1);
        rootGraph.addNode(n2);

        Edge e1 = factory.newEdge(n1, n2);
        rootGraph.addEdge(e1);
View Full Code Here

    @Test
    public void testNodeUserId() {
        GraphFactory factory = graphModel.factory();

        Node n1 = factory.newNode("test");
        rootGraph.addNode(n1);

        assertEquals(n1, rootGraph.getNode("test"));

        rootGraph.setId(n1, "test2");
View Full Code Here

    @Test
    public void testEdgeUserId() {
        GraphFactory factory = graphModel.factory();

        Node n1 = factory.newNode();
        Node n2 = factory.newNode();
        rootGraph.addNode(n1);
        rootGraph.addNode(n2);

        Edge e1 = factory.newEdge("test", n1, n2, 1f, false);
        rootGraph.addEdge(e1);
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.