comp-think / 2021-2022

The GitHub repository containing all the material related to the Computational Thinking and Programming course of the Digital Humanities and Digital Knowledge degree at the University of Bologna (a.a. 2021/2022).
17 stars 9 forks source link

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

Open essepuntato opened 2 years ago

essepuntato commented 2 years ago

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 value of the weight is the number of bibliographic resources (articles, proceedings, etc.) Tim Berners-Lee has co-authored with the person linked by that edge.

MaddaGh commented 2 years ago

Graph1 Graph2

chloeppd commented 2 years ago

from networkx import MultiGraph

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

OrsolaMBorrini commented 2 years ago
from networkx import MultiGraph

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

TBLee_graph.add_edge("Tim Berners Lee","Tom Heath", weight=18)
TBLee_graph.add_edge("Tim Berners Lee","Christian Bizer", weight=18)
TBLee_graph.add_edge("Tim Berners Lee","Sören Auer", weight=10)
TBLee_graph.add_edge("Tim Berners Lee","Lalana Kagal", weight=9)
TBLee_graph.add_edge("Tim Berners Lee","James A. Hendler", weight=8)
Postitisnt commented 2 years ago
from networkx import Graph

TBL_graph = Graph()

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

print(TBL_graph.nodes())
print(TBL_graph.edges(data=True))
AnastasiyaSopyryaeva commented 2 years ago
from networkx import Graph

coauthors = Graph()
coauthors.add_node("Tim Berners Lee")
coauthors.add_edge("Tim Berners Lee", "Tom Heath", weight = 18)
coauthors.add_edge("Tim Berners Lee", "Christian Bizer", weight = 18)
coauthors.add_edge("Tim Berners Lee", "Soren Auer", weight = 10)
coauthors.add_edge("Tim Berners Lee", "Lalana Kagal", weight = 9)
coauthors.add_edge("Tim Berners Lee", "James A. Hendler", weight = 8)

print(coauthors.nodes())
print(coauthors.edges(data=True))
ManueleVeggi commented 2 years ago
from networkx import Graph

tmblGraph = Graph()
tmblGraph.add_node("Tim Berners-Lee")
tmblGraph.add_node("Tom Heath")
tmblGraph.add_node("Christian Bizer")
tmblGraph.add_node("Sören Auer")
tmblGraph.add_node("James A. Hendler")
tmblGraph.add_node("Daniel J. Weitzner")

tmblGraph.add_edge("Tim Berners-Lee", "Tom Heath", weight = 18)
tmblGraph.add_edge("Tim Berners-Lee", "Christian Bizer", weight = 18)
tmblGraph.add_edge("Tim Berners-Lee", "Sören Auer", weight = 10)
tmblGraph.add_edge("Tim Berners-Lee", "James A. Hendler", weight = 9)
tmblGraph.add_edge("Tim Berners-Lee", "Daniel J. Weitzner", weight = 8)
katya-avem commented 2 years ago

image

angstigone commented 2 years ago
Schermata 2021-12-19 alle 19 43 23
AmeliaLamargese commented 2 years ago
from NetworkX import Graph

my_graph = Graph()

my_graph.add_node(1, name = "Tim Berners Lee")
my_graph.add_node(2, name = "Tom Heath")
my_graph.add_node(3, name = "Christian Bizer")
my_graph.add_node(4, name = "Sören Auer")
my_graph.add_node(5, name = "Lalana Kagal")
my_graph.add_node(6, name = "James A. Hendler")

my_graph.add_edge(1, 2, weight = 18)
my_graph.add_edge(1, 3, weight = 18)
my_graph.add_edge(1, 4, weight = 10)
my_graph.add_edge(1, 5, weight = 9)
my_graph.add_edge(1, 6, weight = 8)
NoraPs commented 2 years ago

Cattura