[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/session.php on line 583: sizeof(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/session.php on line 639: sizeof(): Parameter must be an array or an object that implements Countable
Gephi forumsPlease post new questions on facebook group too (https://www.facebook.com/groups/gephi) 2017-10-06T15:37:32+01:00 https://forum-gephi.org/app.php/feed/topic/6290 2017-10-06T15:37:32+01:002017-10-06T15:37:32+01:00 https://forum-gephi.org/viewtopic.php?t=6290&p=14620#p14620 <![CDATA[Re: Apply Force Atlas through Gephi Toolkit]]> https://github.com/gephi/gephi/blob/mas ... tlas2.java
Anyway, you will still get some overlapping labels. That's fixed in Gephi with LabelAdjust layout after force atlas, but I don't think it works with the toolkit yet.

More examples at https://github.com/gephi/gephi-toolkit- ... ayout.java

Statistics:Posted by eduramiba — 06 Oct 2017 15:37


]]>
2017-10-05T14:29:59+01:002017-10-05T14:29:59+01:00 https://forum-gephi.org/viewtopic.php?t=6290&p=14618#p14618 <![CDATA[Apply Force Atlas through Gephi Toolkit]]> I've tried for days to apply the ForceAtlas layout in my project (based on the demo "RankingGraph.java" from https://github.com/gephi/gephi-toolkit-demos), but all I get are stacked points.
Image
Can I get some help?

My class:

CODE:

/*Copyright 2008-2010 GephiAuthors : Mathieu Bastian <mathieu.bastian@gephi.org>Website : http://www.gephi.orgThis file is part of Gephi.Gephi is free software: you can redistribute it and/or modifyit under the terms of the GNU Affero General Public License aspublished by the Free Software Foundation, either version 3 of theLicense, or (at your option) any later version.Gephi is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See theGNU Affero General Public License for more details.You should have received a copy of the GNU Affero General Public Licensealong with Gephi.  If not, see <http://www.gnu.org/licenses/>. */package org.gephi.toolkit.demos;import java.awt.Color;import java.io.File;import java.io.IOException;import org.gephi.appearance.api.AppearanceController;import org.gephi.appearance.api.AppearanceModel;import org.gephi.appearance.api.Function;import org.gephi.appearance.plugin.RankingElementColorTransformer;import org.gephi.appearance.plugin.RankingLabelSizeTransformer;import org.gephi.appearance.plugin.RankingNodeSizeTransformer;import org.gephi.graph.api.Column;import org.gephi.graph.api.DirectedGraph;import org.gephi.graph.api.GraphController;import org.gephi.graph.api.GraphModel;import org.gephi.io.exporter.api.ExportController;import org.gephi.io.importer.api.Container;import org.gephi.io.importer.api.EdgeDirectionDefault;import org.gephi.io.importer.api.ImportController;import org.gephi.io.processor.plugin.DefaultProcessor;import org.gephi.layout.plugin.force.StepDisplacement;import org.gephi.layout.plugin.force.yifanHu.YifanHuLayout;import org.gephi.layout.plugin.forceAtlas.ForceAtlasLayout;import org.gephi.preview.api.PreviewController;import org.gephi.preview.api.PreviewModel;import org.gephi.preview.api.PreviewProperty;import org.gephi.project.api.ProjectController;import org.gephi.project.api.Workspace;import org.gephi.statistics.plugin.GraphDistance;import org.openide.util.Lookup;/** * The demo shows how to do ranking, transform colors and size according to * degree or attribute values. * <p> * The following ranking are applied to the imported network: * <ul><li>Rank node colors by degree</li> * <li>Rank node size by Betweenness Centrality metric</li> * <li>Rank label size by Betweenness Centrality</li> * </ul> * An interpolation can be set to transformers, see * <code>setInterpolator()</code> on transformers. * * @author Mathieu Bastian */public class RankingGraph {    public void script() {        //Init a project - and therefore a workspace        ProjectController pc = Lookup.getDefault().lookup(ProjectController.class);        pc.newProject();        Workspace workspace = pc.getCurrentWorkspace();        //Get controllers and models        ImportController importController = Lookup.getDefault().lookup(ImportController.class);        GraphModel graphModel = Lookup.getDefault().lookup(GraphController.class).getGraphModel();        AppearanceController appearanceController = Lookup.getDefault().lookup(AppearanceController.class);        AppearanceModel appearanceModel = appearanceController.getModel();        //Import file        Container container;        try {            File file = new File(getClass().getResource("/org/gephi/toolkit/demos/lesmiserables.gml").toURI());            container = importController.importFile(file);            container.getLoader().setEdgeDefault(EdgeDirectionDefault.DIRECTED);   //Force DIRECTED        } catch (Exception ex) {            ex.printStackTrace();            return;        }        //Append imported data to GraphAPI        importController.process(container, new DefaultProcessor(), workspace);        //See if graph is well imported        DirectedGraph graph = graphModel.getDirectedGraph();        System.out.println("Nodes: " + graph.getNodeCount());        System.out.println("Edges: " + graph.getEdgeCount());        //Rank color by Degree        Function degreeRanking = appearanceModel.getNodeFunction(graph, AppearanceModel.GraphFunction.NODE_DEGREE, RankingElementColorTransformer.class);        RankingElementColorTransformer degreeTransformer = (RankingElementColorTransformer) degreeRanking.getTransformer();        degreeTransformer.setColors(new Color[]{new Color(0xFEF0D9), new Color(0xB30000)});        degreeTransformer.setColorPositions(new float[]{0f, 1f});        appearanceController.transform(degreeRanking);        //Get Centrality        GraphDistance distance = new GraphDistance();        distance.setDirected(true);        distance.execute(graphModel);        //Rank size by centrality        Column centralityColumn = graphModel.getNodeTable().getColumn(GraphDistance.BETWEENNESS);        Function centralityRanking = appearanceModel.getNodeFunction(graph, centralityColumn, RankingNodeSizeTransformer.class);        RankingNodeSizeTransformer centralityTransformer = (RankingNodeSizeTransformer) centralityRanking.getTransformer();        centralityTransformer.setMinSize(3);        centralityTransformer.setMaxSize(10);        appearanceController.transform(centralityRanking);        //Rank label size - set a multiplier size        Function centralityRanking2 = appearanceModel.getNodeFunction(graph, centralityColumn, RankingLabelSizeTransformer.class);        RankingLabelSizeTransformer labelSizeTransformer = (RankingLabelSizeTransformer) centralityRanking2.getTransformer();        labelSizeTransformer.setMinSize(1);        labelSizeTransformer.setMaxSize(10);        appearanceController.transform(centralityRanking2);                        //Set 'show labels' option in Preview - and disable node size influence on text size        PreviewModel previewModel = Lookup.getDefault().lookup(PreviewController.class).getModel();        previewModel.getProperties().putValue(PreviewProperty.SHOW_NODE_LABELS, Boolean.TRUE);        previewModel.getProperties().putValue(PreviewProperty.NODE_LABEL_PROPORTIONAL_SIZE, Boolean.FALSE);        //Run ForceAtlasLayout for 100 passes - The layout always takes the current visible view        ForceAtlasLayout layout1 = new ForceAtlasLayout(null);        layout1.setGraphModel(graphModel);        layout1.initAlgo();        layout1.resetPropertiesValues();        for (int i = 0; i < 100 && layout1.canAlgo(); i++) {            layout1.goAlgo();        }        layout1.endAlgo();                //Export        ExportController ec = Lookup.getDefault().lookup(ExportController.class);        try {            ec.exportFile(new File("ranking.pdf"));        } catch (IOException ex) {            ex.printStackTrace();            return;        }    }}

Statistics:Posted by thenkron — 05 Oct 2017 14:29


]]>