title: Check if there is any path between two nodes in an undirected graph without going through a particular node
body: <p>I investigated all the possible paths between those two nodes by applying bfs/dfs. Though i'm getting correct result but its taking too much time.
  what should I do ?</p>
  
  <p>Here's my java code of BFS implementation- </p>
  
  <p>Here s = source vertex or first vertex;</p>
  
  <p>d = destination or second vertex;</p>
  
  <p>b = that particular point to avoid.</p>
  
  <pre><code>boolean BFS(int s, int d, int b)
  {
  
      boolean visited[] = new boolean[V];
  
      LinkedList&lt;Integer&gt; queue = new LinkedList&lt;Integer&gt;();
  
      visited[s]=true;
      queue.add(s);
      if(s==b)
          return false;
      upper:
      while (queue.size() != 0)
      {
          s = queue.poll();
          if(s==b)
              continue upper;
          if(s==d)
              return true;
          Iterator&lt;Integer&gt; i = adj[s].listIterator();
          while (i.hasNext())
          {
              int n = i.next();
              if (!visited[n])
              {
                  visited[n] = true;
                  queue.add(n);
              }
          }
      }
      return false;
  }
  </code></pre>
  
  <p>It returns true if there is such path, false if there is no such path.</p>