Como obter os vértices e arestas?
Up to Table of Contents
Como trabalhar com os elementos básicos do grafo?
public class Main {
public static void main(String[] args) throws Exception{
//captura o grafo
IGraph grafo = GraphUtils.getInstance().getGraph("myGraph.graph");
//pega todos os vértices
ArrayList vertices = new ArrayList(grafo.getNodes());
//pega todos as arestas
ArrayList arestas = new ArrayList(grafo.getEdges());
//iterando entre os vertices
Iterator it = vertices.iterator();
while(it.hasNext()){
INode vertice = (INode)it.next();
//faz alguma coisa com o vertice
}
//iterando entre os vertices
Iterator it = arestas.iterator();
while(it.hasNext()){
IEdge aresta = (IEdge)it.next();
//faz alguma coisa com a aresta
}
}
}