Skip to content

Latest commit

 

History

History
40 lines (27 loc) · 558 Bytes

Ex_4_2_04.md

File metadata and controls

40 lines (27 loc) · 558 Bytes
title date draft tags categories
Algorithm4 Java Solution 4.2.04
2020-02-21 06:16:20 +0800
false
JAVA
TECH
archives

4.2.04

Problem:

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.

Solution:

code:

Ex_4_2_04.java

    public boolean hasEdge(int v, int w) {

      for (Integer vv : adj(v)) {
        if (vv==w) return true;
      }

      return false;
    }

Reference: