Created
February 18, 2018 18:10
-
-
Save yaboong/91d9e3fd48f24d7d1716aeb3713fe1f9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.LinkedList; | |
/** | |
* Created by yaboong on 2018. 2. 19.. | |
*/ | |
public class Graph { | |
private final int V; | |
private LinkedList<Integer>[] adj; | |
public Graph(int V) { | |
this.V = V; | |
adj = new LinkedList[V]; | |
for (int v = 0; v < V; v++) | |
adj[v] = new LinkedList<>(); | |
} | |
public void addEdge(int v, int w) { | |
adj[v].add(w); | |
adj[w].add(v); | |
} | |
public Iterable<Integer> adj(int v) { return adj[v]; } | |
public int V() { return V; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment