[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/AllAlgorithms/java/master/graph/BFS.java [Back]  [Original]

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Queue;

/**
 *
 * @author miqdad
 */

class Node{
    int value;
    int index; // represent index of node
    boolean isVisited;
    ArrayList neighbor;
    
    public Node(int index, int value){
        this.index = index;
        this.value = value;
        this.neighbor = new ArrayList();
        this.isVisited = false;
    }
    
    public void addNeighbor(Node node){
        this.neighbor.add(node);
    }
}

class Graph{
    int totalNode;
    Node[] nodes;
    
    public Graph(int totalNode){
        this.totalNode = totalNode;
        nodes = new Node[totalNode];
        for(int i=0; i

Web Proxy Viewer  |  New URL  |  Original Page