# Compute the Centroid Structure

  Functions

  char *vrna_centroid( vrna_fold_compound_t *fc, double *dist)
    #include <ViennaRNA/structures/centroid.h>

    Get the centroid structure of the ensemble.

    The centroid is the structure with the minimal average distance to all other structures \( <d(S)> = \sum_{(i,j) \in S} (1-p_{ij}) + \sum_{(i,j) \notin S} p_{ij} \) Thus, the centroid is simply the structure containing all pairs with \(p_ij>0.5\) The distance of the centroid to the ensemble is written to the memory adressed by dist.

    Parameters:

      - fc – [in] The fold compound data structure

      - dist – [out] A pointer to the distance variable where the centroid distance will be written to

    Returns:

      The centroid structure of the ensemble in dot-bracket notation (`NULL` on error)

  char *vrna_centroid_from_plist(int length, double *dist, vrna_ep_t *pl)
    #include <ViennaRNA/structures/centroid.h>

    Get the centroid structure of the ensemble.

    This function is a threadsafe replacement for centroid() with a vrna_ep_t input

    The centroid is the structure with the minimal average distance to all other structures \( <d(S)> = \sum_{(i,j) \in S} (1-p_{ij}) + \sum_{(i,j) \notin S} p_{ij} \) Thus, the centroid is simply the structure containing all pairs with \(p_ij>0.5\) The distance of the centroid to the ensemble is written to the memory adressed by dist.

    Parameters:

      - length – [in] The length of the sequence

      - dist – [out] A pointer to the distance variable where the centroid distance will be written to

      - pl – [in] A pair list containing base pair probability information about the ensemble

    Returns:

      The centroid structure of the ensemble in dot-bracket notation (`NULL` on error)

  char *vrna_centroid_from_probs(int length, double *dist, FLT_OR_DBL *probs)
    #include <ViennaRNA/structures/centroid.h>

    Get the centroid structure of the ensemble.

    This function is a threadsafe replacement for centroid() with a probability array input

    The centroid is the structure with the minimal average distance to all other structures \( <d(S)> = \sum_{(i,j) \in S} (1-p_{ij}) + \sum_{(i,j) \notin S} p_{ij} \) Thus, the centroid is simply the structure containing all pairs with \(p_ij>0.5\) The distance of the centroid to the ensemble is written to the memory adressed by dist.

    Parameters:

      - length – [in] The length of the sequence

      - dist – [out] A pointer to the distance variable where the centroid distance will be written to

      - probs – [in] An upper triangular matrix containing base pair probabilities (access via iindx vrna_idx_row_wise() )

    Returns:

      The centroid structure of the ensemble in dot-bracket notation (`NULL` on error)