-
Notifications
You must be signed in to change notification settings - Fork 0
/
aif8.pl
68 lines (59 loc) · 1.23 KB
/
aif8.pl
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
67
68
:- dynamic(edge/3).
:- dynamic(node/1).
:- dynamic(visited/1).
select(1) :-
write('Adauga nodul: '),
read(Node),
assert(node(Node)),
menu.
select(2) :-
write('Sterge nodul: '),
read(Node),
node(Node),
retract(node(Node)),
retractall(edge(Node,_,_)),
retractall(edge(_,Node,_)),
menu.
select(3) :-
write('Adauga de la nodul: '),
read(NodeA),
node(NodeA),
write('Pana la: '),
read(NodeB),
node(NodeB),
write('Cost: '),
read(Cost),
assert(edge(NodeA, NodeB, Cost)),
menu.
select(4) :-
write('Sterge de la nodul: '),
read(NodeA),
node(NodeA),
write('Pana la: '),
read(NodeB),
node(NodeB),
retractall(edge(NodeA, NodeB, _)),
menu.
select(5) :-
findall(edge(X, Y, Z), edge(X, Y, Z), Results),
write(Results), nl, menu.
select(6) :-
write('De la nodul: '),
read(NodeA),
node(NodeA),
write('la nodul: '),
read(NodeB),
node(NodeB).
select(7) :-
!.
menu :- write('Meniu:'), nl,
write('\t1.Adauga nod'), nl,
write('\t2.Sterg nod'), nl,
write('\t3.Adauga muchie'), nl,
write('\t4.Sterge muchie'), nl,
write('\t5.Print graph'), nl,
write('\t6.Shortest path'), nl,
write('\t7.Exit'), nl,
write('Choose your destiny: '),
read(Nmb),
select(Nmb).