Course Hero Logo

Grafo.java - import java.util.*; public class Grafo{...

Course Hero uses AI to attempt to automatically extract content from documents to surface to you and others so you can study better, e.g., in search results, to enrich docs, and more. This preview shows page 1 out of 1 page.

import java.util.*;public class Grafo{private ArrayList<Par>[] grafo;private boolean dirigido;public Grafo(int tam, boolean dir){grafo = new ArrayList [tam];dirigido = dir;}public void agregarArista(int origen, int destino, int costo){crearArista(origen, destino, costo);if(!dirigido){crearArista(destino, origen, costo);}}private void crearArista(int origen, int destino, int costo){if(grafo[origen] == null){grafo[origen] = new ArrayList<Par>();}grafo[origen].add(new Par(destino,costo));}public ArrayList<Par> getVecinos(int vo){ArrayList<Par> res = new ArrayList<>();if(grafo[vo] != null){
End of preview. Want to read the entire page?

Upload your study docs or become a

Course Hero member to access this document

Term
Spring
Professor
N/A
Tags
Return statement, Void type, private ArrayList, public class grafo, dirigido

Newly uploaded documents

Show More

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture