Open essepuntato opened 1 year ago
from networkx import DiGrapgh
my_graph = DiGrapgh()
my_graph.add_node("Brad Pitt")
my_graph.add_node("Eva Green")
my_graph.add_node("George Clooney")
my_graph.add_node("Catherine Zeta-Jones")
my_graph.add_node("Johnny Depp")
my_graph.add_node("Helena Bonham Carter")
my_graph.add_node("Ocean's Twelve")
my_graph.add_node("Fight Club")
my_graph.add_node("Dark Shadows")
my_graph.add_edge("Brad Pitt", "Ocean's Twelve")
my_graph.add_edge("George Clooney", "Ocean's Twelve")
my_graph.add_edge("Catherine Zeta-Jones", "Ocean's Twelve")
my_graph.add_edge("Brad Pitt", "Fight Club")
my_graph.add_edge("Helena Bonham Carter", "Fight Club")
my_graph.add_edge("Helena Bonham Carter", "Dark Shadows")
my_graph.add_edge("Johnny Depp", "Dark Shadows")
my_graph.add_edge("Eva Green", "Dark Shadows")
from networkx import DiGraph
movie_graph = DiGraph()
movie_graph.add_node("Brad Pitt")
movie_graph.add_node("Eva Green")
movie_graph.add_node("George Clooney")
movie_graph.add_node("Catherine Zeta-Jones")
movie_graph.add_node("Johnny Depp")
movie_graph.add_node("Helena Bonham Carter")
movie_graph.add_node("Ocean's Twelve")
movie_graph.add_node("Fight Club")
movie_graph.add_node("Dark Shadows")
movie_graph.add_edge("George Clooney", "Ocean's Twelve")
movie_graph.add_edge("Brad Pitt", "Ocean's Twelve")
movie_graph.add_edge("Catherine Zeta-Jones", "Ocean's Twelve")
movie_graph.add_edge("Brad Pitt", "Fight Club")
movie_graph.add_edge("Helena Bonham Carter", "Fight Club")
movie_graph.add_edge("Johnny Depp", "Dark Shadows")
movie_graph.add_edge("Helena Bonham Carter", "Dark Shadows")
movie_graph.add_edge("Eva Green", "Dark Shadows")
I've also tried to visualize it using matplotlib and this is the result:
Create a directed graph that relates the actors Brad Pitt, Eva Green, George Clooney, Catherine Zeta-Jones, Johnny Depp, and Helena Bonham Carter to the following movies: Ocean's Twelve, Fight Club, Dark Shadows.