Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lecture "Organising information: graphs", exercise 1 #35

Open
essepuntato opened this issue Dec 19, 2022 · 2 comments
Open

Lecture "Organising information: graphs", exercise 1 #35

essepuntato opened this issue Dec 19, 2022 · 2 comments
Labels

Comments

@essepuntato
Copy link
Contributor

Consider the list of co-authors of Tim Berners-Lee as illustrated in the right box at http://dblp.uni-trier.de/pers/hd/b/Berners=Lee:Tim. Build an undirected graph containing Tim Berners Lee as the central node, linking it to five nodes representing his top-five co-authors. Also, specify the weight of each edge as an attribute, where the weight value is the number of bibliographic resources (articles, proceedings, etc.) Tim Berners-Lee has co-authored with the person linked by that edge.

@alka2696
Copy link

alka2696 commented Dec 19, 2022

from networkx import Graph

my_graph = Graph()

my_graph.add_node("Tim Berners-Lee")
my_graph.add_node("Tom Heath")
my_graph.add_node("Christian Bizer")
my_graph.add_node("Sören Auer")
my_graph.add_node("Lalana Kagal")
my_graph.add_node("James A. Hendler")

my_graph.add_edge("Tim Berners-Lee", "Tom Heath", weight=18)
my_graph.add_edge("Tim Berners-Lee", "Christian Bizer", weight=18)
my_graph.add_edge("Tim Berners-Lee", "Sören Auer", weight=10)
my_graph.add_edge("Tim Berners-Lee", "Lalana Kagal", weight=9)
my_graph.add_edge("Tim Berners-Lee", "James A. Hendler", weight=8)

@EricaAndreose
Copy link

from networkx import Graph

Tim_Berners_Lee_Graph = Graph()

Tim_Berners_Lee_Graph.add_node("Tim Berners Lee")
Tim_Berners_Lee_Graph.add_node("Tom Heath")
Tim_Berners_Lee_Graph.add_node("Christian Bizer")
Tim_Berners_Lee_Graph.add_node("Sören Auer")
Tim_Berners_Lee_Graph.add_node("Lalana Kagal")
Tim_Berners_Lee_Graph.add_node("James A. Hendler")

Tim_Berners_Lee_Graph.add_edge("Tim Berners Lee", "Tom Heat", weight= 18)
Tim_Berners_Lee_Graph.add_edge("Tim Berners Lee", "Christian Bizer", weight= 18)
Tim_Berners_Lee_Graph.add_edge("Tim Berners Lee", "Sören Auer", weight= 10)
Tim_Berners_Lee_Graph.add_edge("Tim Berners Lee", "Lalana Kagal", weight= 9)
Tim_Berners_Lee_Graph.add_edge("Tim Berners Lee", "James A. Hendler", weight= 8)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants