1%{ @file cache_build_item_graphs.m
2 % @brief Per-item access graph aggregated over users; {} when linear/absent.
4 % @author LINE Development Team
8 % @brief Build per-item (h+1)x(h+1) access graphs from ACCOST.
11 % ACCOST
is the per-(user,item) access graph cell{v,k} (each an (h+1)x(h+1)
12 % matrix). Returns a 1xN cell of per-item graphs aggregated over users by
13 % request rate, or {} when ACCOST
is absent or the standard linear chain (so
14 % the caller keeps the refined/linear path). Row 1
is miss admission, row 1+i
17function G = cache_build_item_graphs(accost, lambda, n, h)
22lin = zeros(h+1, h+1); lin(1, 2) = 1;
23for a = 1:(h-1), lin(a+1, a+2) = 1; end
29 num = zeros(h+1, h+1); den = 0;
31 wv = sum(lambda(v, k, 1));
32 if ~isfinite(wv), wv = 0; end
34 if isempty(gvk),
continue; end
42 if isempty(gk), gk = lin; end
46 if srow > 0, gk(a, :) = gk(a, :) / srow; end
49 if ~all(all(abs(gk - lin) < 1e-9))