Centrality Polarity
PortfolioOptimisers.DistancePolarity — Type
struct DistancePolarity <: AbstractCentralityPolarityDeclares that the edge weights of an algorithm must be distances, where a small value means closely related.
Every algorithm that follows a shortest path needs this polarity, because a shortest path minimises the sum of the weights along it. Over similarities, the same routine takes the route through the weakest links. It returns the reverse answer, and raises no error.
calc_distance_weighted_graph gives this polarity, with distances on both branches.
Related
PortfolioOptimisers.SimilarityPolarity — Type
struct SimilarityPolarity <: AbstractCentralityPolarityDeclares that the edge weights of an algorithm must be similarities, where a large value means closely related.
An algorithm that reads the weighted adjacency matrix, and does not follow a path, needs an entry that grows with the relation. A stronger link must give more.
calc_weighted_adjacency_graph gives this polarity, on its similarity branch only. On the tree branch, calc_mst selects the edges by a minimised distance, and the branch holds no similarity. An algorithm that declares this polarity runs unweighted there.
Related
PortfolioOptimisers.centrality_polarity — Function
centrality_polarity(ct::AbstractCentralityAlgorithm)
centrality_polarity(ct::Union{BetweennessCentrality{<:Any, <:Any, Nothing},
ClosenessCentrality{<:Any, <:Any, Nothing},
StressCentrality{<:Any, <:Any, Nothing},
RadialityCentrality{Nothing}})
centrality_polarity(ct::Union{BetweennessCentrality{<:Any, <:Any, TopologyOnly},
ClosenessCentrality{<:Any, <:Any, TopologyOnly},
StressCentrality{<:Any, <:Any, TopologyOnly},
RadialityCentrality{TopologyOnly}})
centrality_polarity(ct::EigenvectorCentrality{Nothing})
centrality_polarity(ct::EigenvectorCentrality{TopologyOnly})Return the quantity that the edge weights of a centrality algorithm must be.
It is the interface of AbstractCentralityPolarity. centrality_graph reads it, and selects the weights of the network from it.
The answer is the effective polarity, not the declared one
A TopologyOnly in the ov field of the algorithm withdraws the declaration. This function then returns nothing, and the caller gets the plain graph. This function resolves the override, and the call site does not. Three algorithms have no ov field, so a read of ct.ov at the call site fails for them. This function always predicts the graph that centrality_graph builds, and for this reason the library exports it.
The method on the abstract type declares nothing, so a declaration is explicit
The method on AbstractCentralityAlgorithm returns nothing, which selects the plain unweighted graph. A new algorithm runs unweighted until it declares a polarity. This is the safe default. A wrong polarity raises no error, and it reverses the order that the algorithm reads.
What the shipped members declare, and why
DistancePolarity:BetweennessCentrality,ClosenessCentrality,RadialityCentralityandStressCentrality. All four are defined over shortest paths.SimilarityPolarity:EigenvectorCentrality. It is the leading eigenvector of the adjacency matrix, so a larger entry must mean a stronger link.nothing:DegreeCentrality,PagerankandKatzCentrality.Graphs.jlcannot use weights in any of the three. The first two do not read them.Graphs.katz_centralityreadsadjacency_matrix(g, Bool), and throws anInexactErroron a weighted graph.nothing: any of the first five withov = TopologyOnly(). Only those five have the field, because the other three already returnnothingand have nothing to withdraw.
Graphs.jl sets the line between the first two groups and the third. A declaration is about correctness, that is, about which weights. The absence of a declaration is about capability.
Arguments
ct: Centrality algorithm.
Returns
polarity::Option{<:AbstractCentralityPolarity}: The effective polarity, ornothingfor an algorithm that cannot read weights or that withdraws its declaration. Each method returns one concrete type, never aUnion.
Related