Phylogeny Matrix: private API

PortfolioOptimisers._phylogeny_matrixFunction
_phylogeny_matrix(sep::HopCount, nte::AbstractNetworkEstimator,
                  g::Graphs.AbstractGraph)
_phylogeny_matrix(sep::PathLength, nte::AbstractNetworkEstimator,
                  g::Graphs.AbstractGraph)

Internal dispatch helper carrying phylogeny_matrix's per-separation body.

The neighbourhood phylogeny_matrix selects is a question about the separation, not about the estimator, so the split lives here rather than on the public method's argument. Dispatching on the estimator instead would pin the choice to NetworkEstimator and leave every other AbstractNetworkEstimator on one branch — and this family's other kernels, separation_matrix and separation_budget, already take the separation first for the same reason.

The structure arrives built

g is separation_graph's, built once by the public method and shared with resolve_separation, so neither branch derives a distance of its own. nte stays for separation_budget's estimator channel and is otherwise inert here.

The two balls

  • HopCount: the hop ball, sum(A^i for i in 0:n) clamped to 0 or 1, over Graphs.adjacency_matrix(g) — binary, because separation_graph hands a hop count a binarised structure and a power of a weighted matrix would sum products of distances. sep.n is read directly as a matrix-power count rather than through separation_budget, which is what makes it a power count and not a budget.
  • PathLength: the radius ball, separation_matrix thresholded at separation_budget. No second traversal.

Algorithm

Under a HopCount:

  1. Read Graphs.adjacency_matrix off g, giving the binary matrix A.
  2. Accumulate P as the sum of A^i over i in 0:sep.n. Each entry counts the walks of length at most sep.n between its pair.
  3. Clamp P to 0 or 1, which turns the walk count into the selection, and subtract the identity to clear the diagonal.

Under a PathLength:

  1. Measure the separations over g with separation_matrix, giving d.
  2. Resolve the budget with separation_budget, giving dmax.
  3. Select every pair is_related admits at dmax, and subtract the identity to clear the diagonal. is_related carries the unreachable sentinel as well as the budget.

Arguments

  • sep: Separation algorithm, taken from nte.sep by the public method and resolved.
  • nte: Network estimator.
  • g: Structure to read, from separation_graph.

Returns

  • P::Matrix{Int}: Phylogeny matrix. 1 for a related pair, 0 otherwise, 0 on the diagonal.

Related

source