Esempio n. 1
0
import degrees as dg

dg.load_data("large")
dg.names
dg.people
dg.movies

#n = dg.neighbors_for_person('102')

source = '102'
target = '1597'
path = dg.shortest_path(source, target)
if path is None:
    print("Not connected.")
else:
    print(path)
    degrees = len(path)
    print(f"{degrees} degrees of separation.")
    path = [(None, source)] + path
    for i in range(degrees):
        person1 = dg.people[path[i][1]]["name"]
        person2 = dg.people[path[i + 1][1]]["name"]
        movie = dg.movies[path[i + 1][0]]["title"]
        print(f"{i + 1}: {person1} and {person2} starred in {movie}")

#dg.main()
Esempio n. 2
0
def load_small_data():
    dir_path = os.path.dirname(os.path.realpath(__file__))
    load_data(f"{dir_path}/small")
Esempio n. 3
0
 def get_shortest_path(self, directory, sourceName, targetName):
     load_data(directory)
     source = person_id_for_name(sourceName)
     target = person_id_for_name(targetName)
     return shortest_path(source, target)
Esempio n. 4
0
def load_small_database():
    degrees.load_data("small")