Upgrading Gephi 0.8 to 0.9

Gephi’s API had a rather significant API changes; here are some tips for the upgrades.

This nifty repo can get you started quickly: https://github.com/gephi/gephi-plugins

This repo provides good examples of API usage: https://github.com/gephi/gephi-toolkit-demos

API Changes

AttributeColumn subGraphFitnessCol = model.getNodeTable().getColumn(FLD_SUBGRAPH_FITNESS, AttributeType.DOUBLE);

->

Column subGraphCol = graphModel.getNodeTable().getColumn(FLD_GRAPH_FITNESS);

 

AttributeController ac = Lookup.getDefault().lookup(AttributeController.class);
AttributeModel model = ac.getModel();
AttributeColumn fitnessCol = model.getNodeTable().addColumn(“utility”, AttributeType.DOUBLE); // hack: add and then removed

->

graphModel.getNodeTable().

 

..

RankingController rankingController = Lookup.getDefault().lookup(RankingController.class);

// use sub/graph utility (depending on which graph is displayed)
Ranking ranking;
//AttributeModel attributeModel = Lookup.getDefault().lookup(AttributeController.class).getModel();
GraphModel attributeModel = graphModel;

if (jGraph.vertexSet().size() == this.superGraph.vertexSet().size()){
Column col = attributeModel.getNodeTable().getColumn(FLD_GRAPH_FITNESS);
ranking = rankingController.getModel().getRanking(Ranking.NODE_ELEMENT, col.getId() );
} else {
Column col = attributeModel.getNodeTable().getColumn(FLD_SUBGRAPH_FITNESS);
ranking = rankingController.getModel().getRanking(Ranking.NODE_ELEMENT, col.getId() );
}

AbstractSizeTransformer sizeTransformer = (AbstractSizeTransformer) rankingController.getModel().getTransformer(Ranking.NODE_ELEMENT, Transformer.RENDERABLE_SIZE);
sizeTransformer.setMinSize(10);
sizeTransformer.setMaxSize(40);
rankingController.transform(ranking, sizeTransformer);

=>

void size(boolean forceExecution) {
if (this.getIsSize() || forceExecution){
AppearanceController appearanceController = Lookup.getDefault().lookup(AppearanceController.class);
AppearanceModel appearanceModel = appearanceController.getModel();

// Get visible graph
GraphModel graphModel = Lookup.getDefault().lookup(GraphController.class).getGraphModel();
org.gephi.graph.api.Graph gGraph = graphModel.getGraphVisible();
// convert to jgrapht
Graph jGraph = JGraphTUtils.wrap(gGraph);
// update sizes

// use sub/graph utility (depending on which graph is displayed)
Column col;
//AttributeModel attributeModel = Lookup.getDefault().lookup(AttributeController.class).getModel();
GraphModel attributeModel = graphModel;

if (jGraph.vertexSet().size() == this.superGraph.vertexSet().size()){
col = attributeModel.getNodeTable().getColumn(FLD_GRAPH_FITNESS);
} else {
col = attributeModel.getNodeTable().getColumn(FLD_SUBGRAPH_FITNESS);
}

Function sizeRanking = appearanceModel.getNodeFunction(gGraph, col, RankingNodeSizeTransformer.class);
RankingNodeSizeTransformer sizeTransformer = (RankingNodeSizeTransformer) sizeRanking.getTransformer();
sizeTransformer.setMinSize(10);
sizeTransformer.setMaxSize(40);
appearanceController.transform(sizeRanking);

VizController.getInstance().getGraphIO().centerOnGraph();
}
}

 

About Neil Rubens

see http://ActiveIntelligence.org
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *


*