[HUMOR ALERT] Others have given answers that are on topic so mine is not needed. I was amused by the understandable spelling error about doing the unusual variant of a Breath First Search when it is clear they meant Breadth.
But it may apply in this case. The Keven Bacon Game is a variation on calculating the Erdős number. It relates to finding people who were in a film alongside Kevin Bacon and presumably were at some point in close enough proximity to share some component of Breath. They are the closest degree you can get to Kevin without being him. Anyone in a film with one of those people but not directly in a film with Kevin is of a second degree and so on. Still others get the third degree and I won't question that. There are several problems with an approach based on breath. The first is that movies are often made in which the participants work in different areas and never meet. Simply being in the same film does not guarantee that level of closeness. And, I have seen convincing arguments that suggest the likelihood we have all shared the recycled breath of historical figures and very possibly have incorporated atoms that once resided within their bodies into our own. I will spare you the calculations except to say that in some ways we are all one. We have all breathed air that includes minor amounts once in not only a particular Pharaoh in Egypt but also from just about anyone in his kingdom that lived a moderately long life -- no matter where on earth we live. A modern figure like Kevin Bacon gets around and certainly if you live in an area like parts of California he lived in, you may be very close in a Breath First search but without much Depth. And, yes, pythons breathe the same air we do, as do python programmers, just to bring this back to whatever it is we are supposed to waste our breath "talking" about here. -----Original Message----- From: Python-list <python-list-bounces+avigross=verizon....@python.org> On Behalf Of jsk...@gmail.com Sent: Wednesday, January 9, 2019 4:54 AM To: python-list@python.org Subject: Working with graphs - Kevin Bacon game I am working on Kevin Bacon game. I have "movies.txt" text file that looks like: Apollo 13 (1995);Bill Paxton;Tom Hanks;Kevin Bacon Begyndte ombord, Det (1937);Aage Schmidt;Valso Holm Bersaglio mobile (1967);Dana Young;Bebe Drake Bezottsovshchina (1976);Yelena Maksimova;Lev Prygunov Dark, The (1979);Angelo Rossitto;William Devane etc,... So in first row we have movie name, and in other rows we have actors for that movie. I am trying to make Kevin Bacon game with breath-first search. My source code (Python 3.X): class cvor: __slots__ = ('ime','susjed') def kreiranjeCvora(ime): n = cvor() n.ime = ime n.susjed = [] return n def pronadiCvor(cvorlist, ime): for n in cvorlist: if n.ime == ime: return n def ucitajGraf(file): graph = [] for line in file: imeGlumaca = [] mojaLinija = line.split(";") imeFilma = mojaLinija[0] for i in range (1,len(mojaLinija)): imeGlumaca.insert(len(imeGlumaca), mojaLinija[i]) cvorFilm = pronadiCvor(graph, imeFilma) if cvorFilm == None: cvorFilm = kreiranjeCvora(imeFilma) graph.append(cvorFilm) for glumac in imeGlumaca: glumacCvor = pronadiCvor(graph,glumac) if glumacCvor == None: glumacCvor = kreiranjeCvora(glumac) graph.append(glumacCvor) glumacCvor.susjed.append(cvorFilm) cvorFilm.susjed.append(glumacCvor) return graph def main(): f = open("movies.txt") graf = ucitajGraf(f) print (graf) main() My problem is that when I print graph with "print (graph)" I am getting: "[<__main__.cvor object at 0x000001475275EBE0>, <__main__.cvor object at 0x000001475275EEF0>, <__main__.cvor object at 0x000001475275EFD0>, <__main__.cvor object at 0x000001475275EE80>, <__main__.cvor object at 0x000001475275EB70>, <__main__.cvor object at 0x000001475275ED68>,..." And I know why but I don't know how to fix it and get "name" there. What would be the best way to perform breath-first search between two entered names? -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list