Phylogeny

PortfolioOptimisers.BetweennessCentralityType
struct BetweennessCentrality{T1, T2} <: AbstractCentralityAlgorithm
    args::T1
    kwargs::T2
end

Centrality algorithm type for betweenness centrality in PortfolioOptimisers.jl.

BetweennessCentrality computes the betweenness centrality of nodes in a graph, measuring the extent to which a node lies on shortest paths between other nodes.

Fields

  • args: Positional arguments for the centrality computation.
  • kwargs: Keyword arguments for the centrality computation.

Constructor

BetweennessCentrality(; args::Tuple = (), kwargs::NamedTuple = (;))

Keyword arguments correspond to the fields above.

Examples

julia> BetweennessCentrality()
BetweennessCentrality
    args | Tuple{}: ()
  kwargs | @NamedTuple{}: NamedTuple()

Related

source
PortfolioOptimisers.ClosenessCentralityType
struct ClosenessCentrality{T1, T2} <: AbstractCentralityAlgorithm
    args::T1
    kwargs::T2
end

Centrality algorithm type for closeness centrality in PortfolioOptimisers.jl.

ClosenessCentrality computes the closeness centrality of nodes in a graph, measuring how close a node is to all other nodes.

Fields

  • args: Positional arguments for the centrality computation.
  • kwargs: Keyword arguments for the centrality computation.

Constructor

ClosenessCentrality(; args::Tuple = (), kwargs::NamedTuple = (;))

Keyword arguments correspond to the fields above.

Examples

julia> ClosenessCentrality()
ClosenessCentrality
    args | Tuple{}: ()
  kwargs | @NamedTuple{}: NamedTuple()

Related

source
PortfolioOptimisers.DegreeCentralityType
struct DegreeCentrality{T1, T2} <: AbstractCentralityAlgorithm
    kind::T1
    kwargs::T2
end

Centrality algorithm type for degree centrality in PortfolioOptimisers.jl.

DegreeCentrality computes the degree centrality of nodes in a graph, measuring the number of edges connected to each node. The kind parameter specifies the type of degree (0: total, 1: in-degree, 2: out-degree).

Fields

  • kind: Degree type (0: total, 1: in-degree, 2: out-degree).
  • kwargs: Keyword arguments for the centrality computation.

Constructor

DegreeCentrality(; kind::Integer = 0, kwargs::NamedTuple = (;))

Keyword arguments correspond to the fields above.

Validation

  • 0 <= kind <= 2.

Examples

julia> DegreeCentrality(; kind = 1)
DegreeCentrality
    kind | Int64: 1
  kwargs | @NamedTuple{}: NamedTuple()

Related

source
PortfolioOptimisers.KatzCentralityType
struct KatzCentrality{T1} <: AbstractCentralityAlgorithm
    alpha::T1
end

Centrality algorithm type for Katz centrality in PortfolioOptimisers.jl.

KatzCentrality computes the Katz centrality of nodes in a graph, measuring the influence of a node based on the number and length of walks between nodes, controlled by the attenuation factor alpha.

Fields

  • alpha: Attenuation factor for Katz centrality.

Constructor

KatzCentrality(; alpha::Real = 0.3)

Keyword arguments correspond to the fields above.

Examples

julia> KatzCentrality(; alpha = 0.5)
KatzCentrality
  alpha | Float64: 0.5

Related

source
PortfolioOptimisers.PagerankType
struct Pagerank{T1, T2, T3} <: AbstractCentralityAlgorithm
    n::T1
    alpha::T2
    epsilon::T3
end

Centrality algorithm type for PageRank in PortfolioOptimisers.jl.

Pagerank computes the PageRank of nodes in a graph, measuring the importance of nodes based on the structure of incoming links. The algorithm is controlled by the damping factor alpha, number of iterations n, and convergence tolerance epsilon.

Fields

  • n: Number of iterations (must be > 0).
  • alpha: Damping factor (must be in (0, 1)).
  • epsilon: Convergence tolerance (must be > 0).

Constructor

Pagerank(; alpha::Real = 0.85, n::Integer = 100, epsilon::Real = 1e-6)

Keyword arguments correspond to the fields above.

Validation

  • n > 0.
  • 0 < alpha < 1.
  • epsilon > 0.

Examples

julia> Pagerank(; alpha = 0.9, n = 200, epsilon = 1e-8)
Pagerank
        n | Int64: 200
    alpha | Float64: 0.9
  epsilon | Float64: 1.0e-8

Related

source
PortfolioOptimisers.StressCentralityType
struct StressCentrality{T1, T2} <: AbstractCentralityAlgorithm
    args::T1
    kwargs::T2
end

Centrality algorithm type for stress centrality in PortfolioOptimisers.jl.

StressCentrality computes the stress centrality of nodes in a graph, measuring the number of shortest paths passing through each node.

Fields

  • args: Positional arguments for the centrality computation.
  • kwargs: Keyword arguments for the centrality computation.

Constructor

StressCentrality(; args::Tuple = (), kwargs::NamedTuple = (;))

Keyword arguments correspond to the fields above.

Examples

julia> StressCentrality()
StressCentrality
    args | Tuple{}: ()
  kwargs | @NamedTuple{}: NamedTuple()

Related

source
PortfolioOptimisers.KruskalTreeType
struct KruskalTree{T1, T2} <: AbstractTreeType
    args::T1
    kwargs::T2
end

Algorithm type for Kruskal's minimum spanning tree (MST) in PortfolioOptimisers.jl.

KruskalTree specifies the use of Kruskal's algorithm for constructing a minimum spanning tree from a graph.

Fields

  • args: Positional arguments for the MST computation.
  • kwargs: Keyword arguments for the MST computation.

Constructor

KruskalTree(; args::Tuple = (), kwargs::NamedTuple = (;))

Keyword arguments correspond to the fields above.

Examples

julia> KruskalTree()
KruskalTree
    args | Tuple{}: ()
  kwargs | @NamedTuple{}: NamedTuple()

Related

source
PortfolioOptimisers.BoruvkaTreeType
struct BoruvkaTree{T1, T2} <: AbstractTreeType
    args::T1
    kwargs::T2
end

Algorithm type for Boruvka's minimum spanning tree (MST) in PortfolioOptimisers.jl.

BoruvkaTree specifies the use of Boruvka's algorithm for constructing a minimum spanning tree from a graph.

Fields

  • args: Positional arguments for the MST computation.
  • kwargs: Keyword arguments for the MST computation.

Constructor

BoruvkaTree(; args::Tuple = (), kwargs::NamedTuple = (;))

Keyword arguments correspond to the fields above.

Examples

julia> BoruvkaTree()
BoruvkaTree
    args | Tuple{}: ()
  kwargs | @NamedTuple{}: NamedTuple()

Related

source
PortfolioOptimisers.PrimTreeType
struct PrimTree{T1, T2} <: AbstractTreeType
    args::T1
    kwargs::T2
end

Algorithm type for Prim's minimum spanning tree (MST) in PortfolioOptimisers.jl.

PrimTree specifies the use of Prim's algorithm for constructing a minimum spanning tree from a graph.

Fields

  • args: Positional arguments for the MST computation.
  • kwargs: Keyword arguments for the MST computation.

Constructor

PrimTree(; args::Tuple = (), kwargs::NamedTuple = (;))

Keyword arguments correspond to the fields above.

Examples

julia> PrimTree()
PrimTree
    args | Tuple{}: ()
  kwargs | @NamedTuple{}: NamedTuple()

Related

source
PortfolioOptimisers.NetworkEstimatorType
struct NetworkEstimator{T1, T2, T3, T4} <: AbstractNetworkEstimator
    ce::T1
    de::T2
    alg::T3
    n::T4
end

Estimator type for network-based phylogeny analysis in PortfolioOptimisers.jl.

NetworkEstimator encapsulates the configuration for constructing a network from asset data, including the covariance estimator, distance estimator, tree or similarity algorithm, and the network depth parameter.

Fields

  • ce: Covariance estimator.
  • de: Distance estimator.
  • alg: Tree or similarity matrix algorithm.
  • n: NetworkEstimator depth parameter.

Constructor

NetworkEstimator(; ce::StatsBase.CovarianceEstimator = PortfolioOptimisersCovariance(),
                 de::AbstractDistanceEstimator = Distance(; alg = CanonicalDistance()),
                 alg::Union{<:AbstractSimilarityMatrixAlgorithm, <:AbstractTreeType} = KruskalTree(),
                 n::Integer = 1)

Keyword arguments correspond to the fields above.

Examples

julia> NetworkEstimator()
NetworkEstimator
   ce | PortfolioOptimisersCovariance
      |   ce | Covariance
      |      |    me | SimpleExpectedReturns
      |      |       |   w | nothing
      |      |    ce | GeneralWeightedCovariance
      |      |       |   ce | StatsBase.SimpleCovariance: StatsBase.SimpleCovariance(true)
      |      |       |    w | nothing
      |      |   alg | Full()
      |   mp | DefaultMatrixProcessing
      |      |       pdm | Posdef
      |      |           |   alg | UnionAll: NearestCorrelationMatrix.Newton
      |      |   denoise | nothing
      |      |    detone | nothing
      |      |       alg | nothing
   de | Distance
      |   alg | CanonicalDistance()
  alg | KruskalTree
      |     args | Tuple{}: ()
      |   kwargs | @NamedTuple{}: NamedTuple()
    n | Int64: 1

Related

source
PortfolioOptimisers.CentralityEstimatorType
struct CentralityEstimator{T1, T2} <: AbstractCentralityEstimator
    ne::T1
    cent::T2
end

Estimator type for centrality-based analysis in PortfolioOptimisers.jl.

CentralityEstimator encapsulates the configuration for computing centrality measures on a network, including the network estimator and the centrality algorithm.

Fields

  • ne: NetworkEstimator estimator.
  • cent: Centrality algorithm.

Constructor

CentralityEstimator(;
                    ne::Union{<:AbstractPhylogenyEstimator, <:AbstractPhylogenyResult} = NetworkEstimator(),
                    cent::AbstractCentralityAlgorithm = DegreeCentrality())

Keyword arguments correspond to the fields above.

Examples

julia> CentralityEstimator()
CentralityEstimator
    ne | NetworkEstimator
       |    ce | PortfolioOptimisersCovariance
       |       |   ce | Covariance
       |       |      |    me | SimpleExpectedReturns
       |       |      |       |   w | nothing
       |       |      |    ce | GeneralWeightedCovariance
       |       |      |       |   ce | StatsBase.SimpleCovariance: StatsBase.SimpleCovariance(true)
       |       |      |       |    w | nothing
       |       |      |   alg | Full()
       |       |   mp | DefaultMatrixProcessing
       |       |      |       pdm | Posdef
       |       |      |           |   alg | UnionAll: NearestCorrelationMatrix.Newton
       |       |      |   denoise | nothing
       |       |      |    detone | nothing
       |       |      |       alg | nothing
       |    de | Distance
       |       |   alg | CanonicalDistance()
       |   alg | KruskalTree
       |       |     args | Tuple{}: ()
       |       |   kwargs | @NamedTuple{}: NamedTuple()
       |     n | Int64: 1
  cent | DegreeCentrality
       |     kind | Int64: 0
       |   kwargs | @NamedTuple{}: NamedTuple()

Related

source
PortfolioOptimisers.phylogeny_matrixFunction
phylogeny_matrix(ne::AbstractNetworkEstimator, X::AbstractMatrix; dims::Int = 1, kwargs...)

Compute the phylogeny matrix for a network estimator.

This function constructs the adjacency matrix for the network, then computes the phylogeny matrix by summing powers of the adjacency matrix up to the network depth parameter n, clamping values to 0 or 1, and removing self-loops.

Arguments

  • ne: NetworkEstimator estimator.
  • X: Data matrix (observations × assets).
  • dims: Dimension along which to compute (default: 1).
  • kwargs...: Additional keyword arguments.

Returns

  • P::Matrix{Int}: Phylogeny matrix representing asset relationships.

Related

source
phylogeny_matrix(cle::Union{<:AbstractClusteringEstimator, <:AbstractClusteringResult},
                 X::AbstractMatrix; branchorder::Symbol = :optimal, dims::Int = 1,
                 kwargs...)

Compute the phylogeny matrix for a clustering estimator or result.

This function clusterises the data, cuts the tree into the optimal number of clusters, and constructs a binary phylogeny matrix indicating shared cluster membership, with self-loops removed.

Arguments

  • cle: Clustering estimator or result.
  • X: Data matrix (observations × assets).
  • branchorder: Branch ordering strategy for hierarchical clustering (default: :optimal).
  • dims: Dimension along which to compute (default: 1).
  • kwargs...: Additional keyword arguments.

Returns

  • P::Matrix{Int}: Phylogeny matrix representing cluster relationships.

Related

source
PortfolioOptimisers.centrality_vectorFunction
centrality_vector(ne::Union{<:AbstractNetworkEstimator, <:AbstractClusteringEstimator,
                            <:AbstractClusteringResult}, cent::AbstractCentralityAlgorithm,
                  X::AbstractMatrix; dims::Int = 1, kwargs...)

Compute the centrality vector for a network and centrality algorithm.

This function constructs the phylogeny matrix for the network, builds a graph, and computes node centrality scores using the specified centrality algorithm.

Arguments

  • ne: Phylogeny estimator.
  • cent: Centrality algorithm.
  • X: Data matrix (observations × assets).
  • dims: Dimension along which to compute (default: 1).
  • kwargs...: Additional keyword arguments.

Returns

  • cv::Vector{<:Real}: Centrality scores for each asset.

Related

source
centrality_vector(cte::CentralityEstimator, X::AbstractMatrix; dims::Int = 1, kwargs...)

Compute the centrality vector for a centrality estimator.

This function applies the centrality algorithm in the estimator to the network constructed from the data.

Arguments

  • cte: Centrality estimator.
  • X: Data matrix (observations × assets).
  • dims: Dimension along which to compute (default: 1).
  • kwargs...: Additional keyword arguments.

Returns

  • cv::Vector{<:Real}: Centrality scores for each asset.

Related

source
PortfolioOptimisers.average_centralityFunction
average_centrality(ne::Union{<:AbstractPhylogenyEstimator, <:AbstractPhylogenyResult},
                   cent::AbstractCentralityAlgorithm, w::AbstractVector, X::AbstractMatrix;
                   dims::Int = 1, kwargs...)

Compute the weighted average centrality for a network and centrality algorithm.

This function computes the centrality vector and returns the weighted average using the provided weights.

Arguments

  • ne: NetworkEstimator estimator.
  • cent: Centrality algorithm.
  • w: Weights vector.
  • X: Data matrix (observations × assets).
  • dims: Dimension along which to compute (default: 1).
  • kwargs...: Additional keyword arguments.

Returns

  • ac::Real: Average centrality.

Related

source
average_centrality(cte::CentralityEstimator, w::AbstractVector, X::AbstractMatrix;
                   dims::Int = 1, kwargs...)

Compute the weighted average centrality for a centrality estimator.

This function applies the centrality algorithm in the estimator to the network and returns the weighted average using the provided weights.

Arguments

  • cte: Centrality estimator.
  • w: Weights vector.
  • X: Data matrix (observations × assets).
  • dims: Dimension along which to compute (default: 1).
  • kwargs...: Additional keyword arguments.

Returns

  • ac::Real: Average centrality.

Related

source
PortfolioOptimisers.asset_phylogenyFunction
asset_phylogeny(w::AbstractVector, X::AbstractMatrix)

Compute the asset phylogeny score for a set of weights and a phylogeny matrix.

This function computes the weighted sum of the phylogeny matrix, normalised by the sum of absolute weights.

Arguments

  • w: Weights vector.
  • X: Phylogeny matrix.

Returns

  • p::Real: Asset phylogeny score.

Related

source
asset_phylogeny(cle::Union{<:NetworkEstimator, <:ClusteringEstimator}, w::AbstractVector,
                X::AbstractMatrix; dims::Int = 1, kwargs...)

Compute the asset phylogeny score for a set of weights and a network or clustering estimator.

This function computes the phylogeny matrix using the estimator and data, then computes the asset phylogeny score using the weights.

Arguments

  • cle: NetworkEstimator or clustering estimator.
  • w: Weights vector.
  • X: Data matrix (observations × assets).
  • dims: Dimension along which to compute (default: 1).
  • kwargs...: Additional keyword arguments.

Returns

  • p::Real: Asset phylogeny score.

Related

source
PortfolioOptimisers.AbstractCentralityAlgorithmType
abstract type AbstractCentralityAlgorithm <: AbstractPhylogenyAlgorithm end

Abstract supertype for all centrality algorithm types in PortfolioOptimisers.jl from Graphs.jl.

All concrete types implementing specific centrality algorithms (e.g., betweenness, closeness, degree, eigenvector, Katz, pagerank, radiality, stress) should subtype AbstractCentralityAlgorithm. This enables flexible extension and dispatch of centrality routines for network and phylogeny analysis.

Related

source
PortfolioOptimisers.AbstractTreeTypeType
abstract type AbstractTreeType <: AbstractPhylogenyAlgorithm end

Abstract supertype for all minimum spanning tree (MST) algorithm types in PortfolioOptimisers.jl.

All concrete types implementing specific MST algorithms (e.g., Kruskal, Boruvka, Prim) should subtype AbstractTreeType. This enables flexible extension and dispatch of tree-based routines for network and phylogeny analysis.

Related

source
PortfolioOptimisers.calc_mstFunction
calc_mst(alg::AbstractTreeType, g::AbstractGraph)

Compute the minimum spanning tree (MST) of a graph using the specified algorithm.

This function dispatches to the appropriate MST computation from Graphs.jl based on the type of alg. Supported algorithms include Kruskal, Boruvka, and Prim.

Arguments

  • alg: MST algorithm to use.

    • alg::KruskalTree: Computes the MST using Kruskal's algorithm.
    • alg::BoruvkaTree: Computes the MST using Boruvka's algorithm.
    • alg::PrimTree: Computes the MST using Prim's algorithm.
  • g::AbstractGraph: Graph to compute the MST on.

Returns

  • tree::Vector: Vector of edges representing the MST.

Related

source
PortfolioOptimisers.calc_adjacencyFunction
calc_adjacency(ne::NetworkEstimator, X::AbstractMatrix; dims::Int = 1, kwargs...)

Compute the adjacency matrix for a network estimator.

Arguments

  • ne: NetworkEstimator estimator.

    • ne::NetworkEstimator{<:Any, <:Any, <:AbstractTreeType, <:Any}: Constructs a weighted graph from the distance matrix and computes the minimum spanning tree, returning the adjacency matrix of the resulting graph.
    • ne::NetworkEstimator{<:Any, <:Any, <:AbstractSimilarityMatrixAlgorithm, <:Any}: Computes the similarity and distance matrices, applies the PMFG_T2s algorithm, and returns the adjacency matrix of the resulting graph..
  • X: Data matrix (observations × assets).

  • dims: Dimension along which to compute (default: 1).

  • kwargs...: Additional keyword arguments.

Returns

  • adj::Matrix{Int}: Adjacency matrix representing the network.

Related

source
PortfolioOptimisers.calc_centralityFunction
calc_centrality(cent::AbstractCentralityAlgorithm, g::AbstractGraph)

Compute node centrality scores for a graph using the specified centrality algorithm.

This function dispatches to the appropriate centrality computation from Graphs.jl based on the type of cent. Supported algorithms include betweenness, closeness, degree, eigenvector, Katz, pagerank, radiality, and stress centrality.

Arguments

  • cent: Centrality algorithm to use.

    • cent::BetweennessCentrality: Computes betweenness centrality.
    • cent::ClosenessCentrality: Computes closeness centrality.
    • cent::DegreeCentrality: Computes degree centrality.
    • cent::EigenvectorCentrality: Computes eigenvector centrality.
    • cent::KatzCentrality: Computes Katz centrality.
    • cent::Pagerank: Computes PageRank.
    • cent::RadialityCentrality: Computes radiality centrality.
    • cent::StressCentrality: Computes stress centrality.
  • g: Graph to compute centrality on.

Returns

  • Vector{<:Real}: Centrality scores for each node in the graph.

Related

source