title | date | draft | tags | categories | |||
---|---|---|---|---|---|---|---|
Algorithm4 Java Solution 4.2.04 |
2020-02-21 06:16:20 +0800 |
false |
|
|
4.2.4 Add a method hasEdge() to Digraph which takes two int arguments v and w and returns true if the graph has an edge v->w, false otherwise.
code:
public boolean hasEdge(int v, int w) {
for (Integer vv : adj(v)) {
if (vv==w) return true;
}
return false;
}