Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

isConnected method in Graph implementation  RSS feed

 
Vee Cafelle
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!
I have to implement the isConnected() method in my Graph.java implementation, but I'm stuck. This is what I have so far:
import java.util.*;


my isConnected() method:


but I think is not entirely right since I'm always getting true for connectedness. Or maybe I'm just testing it the wrong way? Could anyone verify this for me, please?

 
Paul Clapham
Sheriff
Posts: 22482
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Seems to me you should start out by setting all your vertices to "unmarked" before you start marking the connected vertices.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!