-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
66 lines (49 loc) · 1.74 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#estenzioni per iPython affinchè al cambiamento di un modulo viene ricaricato a runtime
#%load_ext autoreload
#%autoreload 2
from Graph import Graph
#carico il grafo
grafo = Graph('grafi/USAir97.net')
#print del grafo
grafo.info()
#vertex_count
#con log
#grafo.vertex_count(True)
#senza log
grafo.vertex_count()
#vertices
#con proprietà
print("Vertrex list with props")
print("vertices(True) -> " + str(grafo.vertices(True)))
#senza proprietà
print("Vertrex list without props")
print("vertices() -> " + str(grafo.vertices()))
#edge_count
print("Number of edge in the graph")
print("edge_count() -> " + str(grafo.edge_count()))
#edges
print("Edge list")
print("edges() -> " + str(grafo.edges()))
#get_edge(self, u, v, log=False)
print("Search an edge in the graph, u = 118, v = 201")
print("get_edge(u, v, False) ->" + str(grafo.get_edge(118, 201, False)))
#degree
print("Degree")
grafo.degree(201)
#incident_edges
print("Incident edges")
grafo.incident_edges(118, True)
#insert_vertex
grafo.insert_vertex("Pippo")
grafo.insert_vertex("Pluto")
grafo.insert_vertex("Paperino")
grafo.insert_vertex("Minnie")
grafo.insert_vertex("Zio Paperone")
print("Now the Vertrex list with props is")
print("vertices(True) -> " + str(grafo.vertices(True)))
#insert an edge
print("Edge inserted using insert_edge(335, 336) -> " + str(grafo.insert_edge(335, 336)))
print("remove a vertrex using remove_vertex(334) -> " + str(grafo.remove_vertex(334)))
print("if i will try to remove a non existent vertex using remove_vertex(334) -> " + str(grafo.remove_vertex(334)))
print("remove an existent edge using remove_edge((335,336)) -> " + str(grafo.remove_edge((335,336))))
print("remove a non existent edge using remove_edge((335,336)) -> " + str(grafo.remove_edge((335,336))))