Python Forum
Kevin Bacon game with breath-first search
Thread Rating:
  • 2 Vote(s) - 4.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Kevin Bacon game with breath-first search
#2
What you are seeing is the default text representation (repr) of the object you have created. That may be the correct answer, but it's not showing you the information to determine that. You need to override the __repr__ method of cvor so that it gives you better info. Your cvor (I'm not sure if this is the actor or the film) class is very bare bones, I would expand it:

class cvor(object):

    def __init__(self, ime):
        self.ime = ime
        self.susjed = []

    def __repr__(self):
        return '<cvor {} ({})>'.format(self.ime, len(self.susjed))
Now you don't need kreiranjeCvora. You can just do cvorFilm = cvor(imeFilma). Also, the output you get should be more intelligible.

BTW, it's breadth-first search, with a d. Breath is taking in air through your mouth and nose, breadth is how wide something is.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
RE: Kevin Bacon game with breath-first search - by ichabod801 - Jan-09-2019, 03:04 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020