# libpysal.graph.GraphSummary

class libpysal.graph.GraphSummary(graph, asymmetries=False)

  Graph Summary

  An object containing the statistical attributes summarising the Graph and its basic properties.

  Attributes:
    n_nodes `python:int`

      number of Graph nodes

    n_edges `python:int`

      number of Graph edges

    n_components `python:int`

      number of connected components

    n_isolates `python:int`

      number of isolates (nodes with no neighbors)

    nonzero `python:int`

      number of edges with nonzero weight

    pct_nonzero `python:float`

      percentage of nonzero weights

    n_asymmetries `python:int`

      number of intrinsic asymmetries

    cardinalities_mean `python:float`

      mean number of neighbors

    cardinalities_std `python:float`

      standard deviation of number of neighbors

    cardinalities_min `python:float`

      minimal number of neighbors

    cardinalities_25 `python:float`

      25th percentile of number of neighbors

    cardinalities_50 `python:float`

      50th percentile (median) of number of neighbors

    cardinalities_75 `python:float`

      75th percentile of number of neighbors

    cardinalities_max `python:float`

      maximal number of neighbors

    weights_mean `python:float`

      mean edge weight

    weights_std `python:float`

      standard deviation of edge weights

    weights_min `python:float`

      minimal edge weight

    weights_25 `python:float`

      25th percentile of edge weights

    weights_50 `python:float`

      50th percentile (median) of edge weights

    weights_75 `python:float`

      75th percentile of edge weights

    weights_max `python:float`

      maximal edge weight

    s0 `python:float`

      S0 (global) sum of weights

      `s0` is defined as

      \[s0=\sum_i \sum_j w_{i,j}\]

      `s0`, `s1`, and `s2` reflect interaction between observations and are used to compute standard errors for spatial autocorrelation estimators.

    s1 `python:float`

      S1 sum of weights

      `s1` is defined as

      \[s1=1/2 \sum_i \sum_j \Big(w_{i,j} + w_{j,i}\Big)^2\]

      `s0`, `s1`, and `s2` reflect interaction between observations and are used to compute standard errors for spatial autocorrelation estimators.

    s2 `python:float`

      S2 sum of weights

      `s2` is defined as

      \[s2=\sum_j \Big(\sum_i w_{i,j} + \sum_i w_{j,i}\Big)^2\]

      `s0`, `s1`, and `s2` reflect interaction between observations and are used to compute standard errors for spatial autocorrelation estimators.

    diag_g2 `np.ndarray`

      diagonal of \(GG\)

    diag_gtg `np.ndarrray`

      diagonal of \(G^{'}G\)

    diag_gtg_gg `np.ndarray`

      diagonal of \(G^{'}G + GG\)

    trace_g2 `np.ndarray`

      trace of \(GG\)

    trace_gtg `np.ndarrray`

      trace of \(G^{'}G\)

    trace_gtg_gg `np.ndarray`

      trace of \(G^{'}G + GG\)

  Examples

      >>> import geopandas as gpd
      >>> from geodatasets import get_path
      >>> nybb = gpd.read_file(get_path("nybb")).set_index("BoroName")
      >>> nybb
                      BoroCode  ...                                           geometry
      BoroName                 ...
      Staten Island         5  ...  MULTIPOLYGON (((970217.022 145643.332, 970227....
      Queens                4  ...  MULTIPOLYGON (((1029606.077 156073.814, 102957...
      Brooklyn              3  ...  MULTIPOLYGON (((1021176.479 151374.797, 102100...
      Manhattan             1  ...  MULTIPOLYGON (((981219.056 188655.316, 980940....
      Bronx                 2  ...  MULTIPOLYGON (((1012821.806 229228.265, 101278...
      [5 rows x 4 columns]

      >>> contiguity = graph.Graph.build_contiguity(nybb)
      >>> contiguity
      <Graph of 5 nodes and 10 nonzero edges indexed by
          ['Staten Island', 'Queens', 'Brooklyn', 'Manhattan', 'Bronx']>

      >>> summary = contiguity.summary(asymmetries=True)
      >>> summary
      Graph Summary Statistics
      ========================
      Graph indexed by:
      ['Staten Island', 'Queens', 'Brooklyn', 'Manhattan', 'Bronx']
      ==============================================================
      number of nodes:                                             5
      number of edges:                                            10
      number of connected components:                              2
      number of isolates:                                          1
      number of non-zero edges:                                   10
      Percentage of non-zero edges:                           44.00%
      number of asymmetries:                                       0
      --------------------------------------------------------------
      Cardinalities
      ==============================================================
      Mean:                       2    25%:                        2
      Standard deviation:         1    50%:                        2
      Min:                        0    75%:                        3
      Max:                        3
      --------------------------------------------------------------
      Weights
      ==============================================================
      Mean:                       1    25%:                        1
      Standard deviation:         0    50%:                        1
      Min:                        1    75%:                        1
      Max:                        1
      --------------------------------------------------------------
      Sum of weights
      ==============================================================
      S0:                                                         10
      S1:                                                         20
      S2:                                                        104
      --------------------------------------------------------------
      Traces
      ==============================================================
      GG:                                                         10
      G'G:                                                        10
      G'G + GG:                                                   20

      >>> summary.s1
      20

  __init__(graph, asymmetries=False)

    Create GraphSummary

    Parameters:
      graph `Graph`
      asymmetries bool

        whether to compute `n_asymmetries`, which is considerably more expensive than the other attributes. By default False.

  Methods

  `__init__`(graph[, asymmetries]) | Create GraphSummary