gephi-toolkit-demos icon indicating copy to clipboard operation
gephi-toolkit-demos copied to clipboard

How can I output the filtered graph using the toolkit 0.9.1

Open ZhitongLei opened this issue 9 years ago • 0 comments

I'm trying to filter a graph by node degree using the toolkit 0.9.1. The number of nodes is ok after filtered, but after exporting the graph, I can find the filtered nodes in the gexf file. So how I can output the filtered graph? Thanks.

    GraphModel graphModel = Lookup.getDefault().lookup(GraphController.class).getGraphModel();
    FilterController filterController = Lookup.getDefault().lookup(FilterController.class);
    DegreeRangeFilter degreeFilter = new DegreeRangeFilter();
    degreeFilter.init(graphModel.getGraph());
    degreeFilter.setRange(new Range(1, Integer.MAX_VALUE));     //Remove isolated nodes
    Query query = filterController.createQuery(degreeFilter);
    GraphView view = filterController.filter(query);
    graphModel.setVisibleView(view);    //Set the filter result as the visible view

    // See if graph is well imported and filtered
    graph = graphModel.getDirectedGraphVisible();
    System.out.println("Nodes: " + graph.getNodeCount());   // number of nodes is ok after filtered
    System.out.println("Edges: " + graph.getEdgeCount())

    ExportController ec = Lookup.getDefault().lookup(ExportController.class)
    ec.exportFile(new File(outputFile)) ;  // filtered nodes is still in outputFile

ZhitongLei avatar Oct 16 '16 07:10 ZhitongLei