def getMaxBoxOfficeFilm(self, filmNodes): maxVal = 0 act = '' for node in filmNodes: if (float(FilmNode.getValue(node)) > maxVal): maxVal = float(FilmNode.getValue(node)) act = FilmNode.getName(node) return act
def show_age_gross_relation(): ret = {} for film in InitGraph.filmNodes: if film is not None: value = FilmNode.getValue(film) name = FilmNode.getName(film) actors = GraphQuery.getActorsInFilm(GraphQuery(), InitGraph.filmNameDict, name) for actor in actors: if actor is not None: for node in InitGraph.actorNodes: if ActorNode.getName(node) == actor: ret[ActorNode.getAge(node)] = value trace = go.Pie(labels=list(ret.keys()), values=list(ret.values())) py.plot([trace], filename='basic_pie_chart')
def show_actor_earnings(): ret = {} for film in InitGraph.filmNodes: if film is not None: value = float(FilmNode.getValue(film)) name = FilmNode.getName(film) actors = GraphQuery.getActorsInFilm(GraphQuery(), InitGraph.filmNameDict, name) for actor in actors: if actor is not None: if ret.get(actor) is None: ret[actor] = 0.0 ret[actor] += value labels = list(ret.keys()) values = list(ret.values()) trace = go.Pie(labels=labels, values=values) py.plot([trace], filename='basic_pie_chart')
def getFilmValue(self, filmNodes, filmName): for node in filmNodes: if (FilmNode.getName(node) == filmName): return FilmNode.getValue(node)
def removeFilm(self, filmNodes, filmNameDict, filmName): for node in filmNodes: if FilmNode.getName(node) == filmName: filmNodes.remove(node) filmNameDict.pop(filmName)
def getOtherFilms(self, filmNodes, filmName): ret = [] for node in filmNodes: if FilmNode.getName(node).find(filmName) == -1: ret.append(FilmNode.getName(node)) return ret
def getAllFilmsInYear(self, filmNodes, year): ret = [] for node in filmNodes: if FilmNode.getYear(node) == str(year): ret.append(FilmNode.getName(node)) return ret