Personal tools
You are here: Home Documentação Snippets de código Como obter os vértices e arestas?
Document Actions

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
}

     
    }

}
by ugorox last modified 2006-11-19 22:27
Navigation
Log in


Forgot your password?
New user?
 

Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: