more updates to meld.

This commit is contained in:
Vitor Santos Costa
2011-05-11 09:28:40 +01:00
parent bbf83cb34d
commit 7122c657c0
5 changed files with 58 additions and 22 deletions

View File

@@ -0,0 +1,7 @@
%edge(0,1).
%edge(0,4).
%edge(1,4).
%edge(1,2).
edge(2,3).
edge(2,4).
edge(3,4).

View File

@@ -1,20 +1,24 @@
type rank(node, int, float).
type reachable(node, node).
type calcRank(node, int, sum float).
type persistent numPages(node, int).
% type persistent numPages(node, int).
type persistent numPages(node, sum int).
type numLinks(node, sum int).
type path(node, node).
const damping = 0.85.
const num_iterations = 4.
% extern float to_float(int).
% extern float float_abs(float).
rank(A, 0, 1.0 / to_float(T)) :- numPages(A, T).
rank(A, 0, 1.0 / to_float(T)) :- numPages(A,T).
rank(A, I, V) :-
numPages(A, Ps),
calcRank(A, I, T),
Before = I - 1,
rank(A, Before, VOld),
V = damping + (1.0 - damping) * T,
V = (damping + (1.0 - damping) * T)/to_float(Ps),
I =< num_iterations.
% //float_abs((damping + (1.0 - damping) * T) - VOld) > 0.001.
@@ -27,8 +31,17 @@ calcRank(A, I + 1, O / to_float(C)) :-
numLinks(A, 1) :-
edge(A,B).
numPages(A, 1) :-
numPages(A, 1) :- path(A,_).
path(A, B) :-
edge(A,B).
path(A, B) :-
edge(B,A).
path(A, B) :-
edge(A,C),
path(C,B).
path(A, B) :-
edge(C,A),
path(C,B).