use of org.gephi.graph.api.Graph in project gephi by gephi.
the class StandardTest method test.
@Test
public void test() {
Graph graph = generateGraph();
AppearanceModelImpl model = new AppearanceModelImpl(workspace);
Function[] funcs = model.getNodeFunctions(graph);
// for(Function f: funcs) {
// System.out.println(f);
// }
}
use of org.gephi.graph.api.Graph in project gephi by gephi.
the class StandardTest method generateGraph.
// UTILITY
private Graph generateGraph() {
GraphFactory factory = graphModel.factory();
Node[] nodes = new Node[6];
for (int i = 0; i < nodes.length; i++) {
nodes[i] = factory.newNode();
}
Graph graph = graphModel.getGraph();
graph.addAllNodes(Arrays.asList(nodes));
Column column1 = graphModel.getNodeTable().addColumn("part1", String.class);
Column column2 = graphModel.getNodeTable().addColumn("rank2", Integer.class);
for (int i = 0; i < nodes.length; i++) {
nodes[i].setAttribute(column2, i);
nodes[i].setAttribute(column1, i % 2 == 0 ? "A" : "B");
}
return graph;
}
use of org.gephi.graph.api.Graph in project gephi by gephi.
the class AppearanceControllerImpl method transform.
@Override
public void transform(Function function) {
if (model != null) {
GraphModel graphModel = model.getGraphModel();
Graph graph = graphModel.getGraphVisible();
ElementIterable<? extends Element> iterable;
if (function.getElementClass().equals(Node.class)) {
iterable = graph.getNodes();
} else {
iterable = graph.getEdges();
}
try {
for (Element element : iterable) {
function.transform(element, graph);
}
} catch (Exception e) {
iterable.doBreak();
if (e instanceof RuntimeException) {
throw (RuntimeException) e;
} else {
throw new RuntimeException(e);
}
}
}
}
use of org.gephi.graph.api.Graph in project gephi by gephi.
the class ExporterCSV method execute.
@Override
public boolean execute() {
GraphModel graphModel = workspace.getLookup().lookup(GraphModel.class);
Graph graph = exportVisible ? graphModel.getGraphVisible() : graphModel.getGraph();
graph.readLock();
try {
exportData(graph);
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
graph.readUnlock();
Progress.finish(progressTicket);
}
return !cancel;
}
use of org.gephi.graph.api.Graph in project gephi by gephi.
the class ExporterGML method execute.
@Override
public boolean execute() {
GraphController graphController = Lookup.getDefault().lookup(GraphController.class);
graphModel = graphController.getGraphModel(workspace);
Graph graph = exportVisible ? graphModel.getGraphVisible() : graphModel.getGraph();
Progress.start(progressTicket, graph.getNodeCount() + graph.getEdgeCount());
graph.readLock();
try {
if (normalize) {
computeNormalizeValues(graph);
}
exportData(graph);
} catch (IOException e) {
Logger.getLogger(ExporterGML.class.getName()).log(Level.SEVERE, null, e);
} finally {
graph.readUnlock();
Progress.finish(progressTicket);
}
return !cancel;
}
Aggregations