Function S2Shape.numChains

Returns the number of contiguous edge chains in the shape. For example, a shape whose edges are [AB, BC, CD, AE, EF] would consist of two chains (AB,BC,CD and AE,EF). Every chain is assigned a "chain id" numbered sequentially starting from zero.

abstract int numChains() const;

Note that it is always acceptable to implement this method by returning num_edges() (i.e. every chain consists of a single edge), but this may reduce the efficiency of some algorithms.