tree - shaped objects are fundamental in nature , where they appear , e.g. , as delivery systems for gases and fluids @xcite , as skeletal structures , or describing hierarchies .
examples encountered in image analysis and computational biology are airway trees  @xcite , vascular systems  @xcite , shock graphs  @xcite , scale space hierarchies  @xcite and phylogenetic trees @xcite .    statistical methods for tree - structured data would have endless applications .
for instance , one could make more consistent studies of changes in airway geometry and structure related to airway disease  @xcite to improve tools for computer aided diagnosis and prognosis .    due to the wide range of applications ,
extensive work has been done in the past @xmath0 years on comparison of trees and graphs in terms of matching  @xcite , object recognition  @xcite and machine learning  @xcite based on inter - tree distances .
however , the existing tree - distance frameworks are algorithmic rather than geometric .
very few attempts  @xcite have been made to build analogues of the theory for landmark point shape spaces using manifold statistics and riemannian submersions  @xcite .
there exists no principled approach to studying the space of tree - structured data , and as a consequence , the standard statistical properties are not well - defined . as we shall see , difficulties appear even in the basic problem of finding the average of two tree - shapes .
this paper fills the gap by introducing a shape - theoretical framework for geometric trees , which is suitable for statistical analysis .
most statistical measurements are based on a concept of distance .
the most fundamental statistic is the _
mean _ ( or prototype ) @xmath1 for a dataset @xmath2 , which can be defined as the minimizer of the sum of squared distances to the data points : @xmath3 this definition of the mean , called _ frchet mean _
, assumes a space of tree - shapes endowed with a distance @xmath4 , and is closely connected to geodesics , or shortest paths , between tree - shapes .
for example , the midpoint of a geodesic from @xmath5 to @xmath6 is a mean for the two - point dataset @xmath7 .
hence , if there are multiple geodesics connecting @xmath5 to @xmath6 , with different midpoints , then there will also be multiple means .
_ as a consequence , without ( local , generic ) uniqueness of geodesics , statistical properties are fundamentally ill - posed ! _
thus , geometry enters the picture , and the idea of a geodesic tree - space gives a constraint on the possible geometric structure of tree - space . in a shape space where distances are given by path length
, we must be able to continuously deform any given tree - shape into any other by traveling along the shortest path that connects the two shapes .
the deformation - paths are easy to describe when only branch shape is changed , while tree topology ( branch connectivity ) is fixed .
such deformations take place in portions of tree - space where all trees have the same topological structure .
it is more challenging to describe deformation - paths in which the tree - topological structure is changed , for instance through a collapsed internal branch as in fig .
[ treetopologyviolationgeodesic ] .
we model topologically intermediate trees as collapsed versions of trees with differing tree topology , and glue the portions of tree - space together along subspaces that correspond to collapsed trees , as in fig .
[ tree_space_components ] . as a consequence ,
tree - space has self intersections and is not smooth , but has singularities !
the main theoretical contributions of this paper are the construction of a mathematical tree - shape framework along with a geometric analysis of two natural metrics on the shape space .
one of these metrics is the classical tree edit distance ( ted ) , into which we gain new insight .
the second metric , called quotient euclidean distance ( qed ) , is induced from a euclidean metric .
using gromov s approach to metric geometry @xcite , we show that qed generically gives locally unique geodesics and means , whereas finding geodesics and means for ted is ill - posed even locally .
we explain why using ted for computing average trees must always be accompanied by a carefully engineered choice of edit paths in order to give well - defined results ; choices which can yield average trees which are substantially different from the trees in the dataset  @xcite .
the qed approach , on the contrary , allows us to investigate statistical methods for tree - like structures which have previously not been possible , like different well - defined concepts of average tree .
_ this is our motivation for studying the qed metric ! _
the paper is organized as follows : in section  [ background ] we discuss related work . the tree - space is defined in section  [ geometrysection ] , and the statistical properties of tree - space are analyzed in section  [ curvaturesection ] . in section  [ complexitysection ] ,
we discuss how to overcome the computational complexity of both metrics , and present a simple qed approximation . in section  [ experimentalsection ]
, we illustrate the properties of qed by computing geodesics and different types of average tree for synthetic planar data trees as well as by computing qed means for sets of @xmath8 airway trees from human lungs .
metrics on sets of tree - structured data have been studied by different research communities for the past 20 years .
the best - known approach is perhaps tree edit distance ( ted ) , which has been used extensively for shape matching and recognition based on medial axes and shock graphs  @xcite .
ted and , more generally , graph edit distance ( ged ) , are also popular in the pattern recognition community , and are still used for distance - based pattern recognition approaches to trees and graphs  @xcite .
the ted and ged metrics will nearly always have infinitely many shortest edit paths , or geodesics , between two given trees , since edit operations can be performed in different orders and increments . as a result ,
even the problem of finding the average of two trees is not well posed . with no kind of uniqueness of geodesics , it becomes hard to meaningfully define and compute average shapes or modes of variation .
this problem can be solved to some extent by choosing a preferred edit path  @xcite , but there will always be a risk that the choice has negative consequences in a given setting .
trinh and kimia  @xcite face this problem when they use ted for computing average medial axes using the simplest possible edit paths , leading to average shapes which can be substantially different from most of the dataset shapes .
statistics on tree - shaped objects receive growing interest in the statistical community .
wang and marron  @xcite study metric spaces of trees and define a notion of average tree called the median - mean as well as a version of pca , which finds modes of variation in terms of _ tree - lines _
, encoding the maximum amount of structural and attributal variation .
aydin et al .  @xcite extend this work by finding efficient algorithms for pca .
this is applied to analysis of brain blood vessels .
the metric defined by wang and marron does not give a natural geodesic structure on the space of trees , as it places a large emphasis on the tree - topological structure of the trees .
the metric has discontinuities in the sense that a sequence of trees with a shrinking branch will not converge to a tree that does not have that branch .
such a metric is not suitable for studying trees with continuous topological variations and noise , such as anatomical tree - structures extracted from medical images , since the emphasis on topology makes the metric sensitive to structural noise .
a different approach is that of jain and obermayer @xcite , who study metrics on attributed graphs , represented as incidence matrices .
the space of graphs is defined as a quotient of the euclidean space of incidence matrices by the group of vertex permutations .
the graph - space inherits the euclidean metric , giving it the structure of an orbifold .
this graph - space construction is similar to the tree - space presented in this paper in the sense that both spaces are constructed as quotients of a euclidean space .
the graph - space framework does not , however , give continuous transitions in internal graph - topological structure , which leads to large differences between the geometries of the tree- and graph - spaces .
trees also appear in genetics .
hillis et al .
@xcite visualize large sets of phylogenetic trees using multidimensional scaling .
billera et al .
@xcite have invented a phylogenetic tree - space suitable for geodesic analysis of phylogenetic trees , and owen and provan  @xcite have developed fast algorithms for computing geodesics in phylogenetic tree - space .
nye  @xcite has developed a notion of pca in phylogenetic tree - space , but is forced to make strict assumptions on possible principle components being  simple lines  for the sake of computability .
phylogenetic trees are not geometric , and have fixed , labeled leaf sets , making the space of phylogenetic trees much simpler than the space of tree - like shapes .
we have previously @xcite studied geodesics between small tree - shapes in the same type of singular shape space as studied here , but most proofs have been left out . in  @xcite , we study different algorithms for computing average trees based on the qed metric .
this paper extends and continues  @xcite , giving proofs , in - depth explanations and more extensive examples illustrating the potential of the qed metric .
let us discuss which properties are desirable for a tree - shape model . as previously discussed , we require , at the very least , local existence and uniqueness for geodesics in order to compute average trees and analyze variation in datasets . when geodesics exist , we want the topological structure of the intermediate trees along the geodesic to reflect the resemblance in structure of the trees being compared .
in particular , _ a geodesic passing through the trivial one - vertex tree should indicate that the trees being compared are maximally different .
_ perhaps more importantly , we would like to compare trees where the desired edge matching is inconsistent with tree topology , as in fig .
[ treetopologyviolation ] . specifically
, we would like to find geodesic deformations in which the tree topology changes when we have such edge matchings , for instance as in fig .
[ treetopologyviolationgeodesic ] .      in this paper
we shall work with two different tree - spaces : a tree - space @xmath9 , which is the space of all trees of a certain size , and a subspace @xmath10 , which is a restricted space of trees , whose exact definition is flexible ( see definition  [ subspacedef ] ) .
the large tree - space @xmath9 is the natural space for geometric trees .
however , the available mathematical tools only allow us to prove our results locally , where the locality assumptions become very strict in @xmath9 . using a set of natural assumptions
, we can restrict to a tree - space @xmath11 where our results hold in larger regions of tree - space .
this is discussed in detail in section  [ injectivity ] .
we also believe that our results hold in @xmath9 , as described in conjecture  [ conjecture ] .    in this paper , a  tree - shape
is an embedded tree in @xmath12 or @xmath13 , and consists of a series of edge embeddings , glued together according to a rooted combinatorial tree .
tree - shapes are invariant to translation , but our definition of tree - shape does not remove scale and rotation . however , tree - shapes can always be aligned with respect to scale and rotation prior to comparison , if this is important .    any tree - like shape is represented as a pair @xmath14 consisting of a rooted , planar tree @xmath15 with edge attributes @xmath16 . in @xmath17 , @xmath18 is the vertex set , @xmath19 is the edge set , and @xmath20 is the root vertex .
the tree @xmath15 describes the tree - shape topology , and the attributes describe edge shape , as illustrated in fig .
[ pickapart ] .
the shape attributes , represented by a point @xmath21 in the product space @xmath22 , is a concatenation of edgewise attributes from an attribute space @xmath23 .
the attributes could , e.g. , be edge length , landmark points or edge parametrizations . in this work
, we mostly use open curves translated to start at the origin , described by a fixed number of landmark points along the edge .
thus , throughout the paper , the attribute space @xmath23 is @xmath24 where @xmath25 or @xmath26 and @xmath27 is the number of landmark points per edge . collapsed edges are represented by a sequence of origin points .
in some illustrations , we shall use scalar attributes for the sake of visualization , in which case @xmath28 .    in order to compare trees of different sizes and structures ,
we need to represent them in a unified way .
we describe all shapes using the _ same _ tree @xmath15 to encode tree topology . by choosing a sufficiently large @xmath15 , we can represent all the trees in our dataset by filling out with empty ( collapsed ) edges .
we call @xmath15 _ the maximal tree_.    we model tree - shapes using _ binary _ maximal trees @xmath15 .
tree - shapes which are not binary are represented by the binary tree @xmath15 in a natural way by allowing constant , or collapsed , edges , represented by the zero scalar or vector attribute . in this way _ an arbitrary attributed tree can be represented as an attributed * binary * tree _ , see fig .
[ constedge ] .
this is geometrically very natural .
binary trees are geometrically _ stable _ in the sense that small perturbations of a binary tree - shape do not change the tree - topological structure of the shape .
conversely , a trifurcation or higher - order vertex can always be turned into a series of bifurcations sitting close together by an arbitrarily small perturbation . in our representation , thus , trifurcations are represented as two bifurcations sitting infinitely close together , etc .
trees embedded in the plane have a natural edge order induced by the left - right order on the children of any edge .
we say that a tree is _ ordered _ whenever each set of sibling edges in the tree is endowed with such a total order .
conversely , an ordered combinatorial tree always has a unique , implicit embedding in the plane where siblings are ordered from left to right .
for this reason we use the terms  planar tree  and  ordered tree  interchangingly .
we initially study metrics on the set of ordered binary trees ; later we use them to induce distances between unordered trees by considering all possible orders .
this allows us to model trees in @xmath13 . considering all orders
leads to potential computational challenges , which are discussed in section  [ complexitysection ] .    - and @xmath29-axes are trees with a single branch . for each real number @xmath30 , the tree - shape found at @xmath31
is also represented at @xmath32 .
we build the tree - shape space by gluing the different representations of the same tree - shapes ( e.g. , @xmath33 and @xmath34 ) together , obtaining the shape space shown on the right .
note the path from @xmath35 to @xmath36 through @xmath37 in @xmath38 on the right ; the corresponding path in the pre - shape space @xmath9 involves a  teleportation  between the representations @xmath33 and @xmath39 of @xmath37 . ]    in order to build a space of tree - shapes , fix an ordered maximal binary tree @xmath15 with edges @xmath40 , which encodes the connectivity of all our trees .
any attributed tree @xmath33 is now represented by a point @xmath41 in @xmath42 , where the coordinate @xmath43 describes the shape of the edge @xmath44 .
since we allow zero - attributed edges , as discussed above , some tree - shapes will be represented by several points in @xmath9 ( fig .
[ constedge ] ) . as a result
, some natural tree - deformations are not found as continuous paths in @xmath9 . in figs .
[ tedmoves4 ] and  [ folding ] , the paths in @xmath9 corresponding to the indicated deformations require a  teleportation  between two representations of the intermediate tree - shape .
we tackle this by using a refined tree - shape space @xmath38 , where different representations are identified as being the same point .
the original space @xmath9 is called the tree pre - shape space , analogous to kendall s terminology  @xcite .
we go from pre - shapes to shapes by identifying those pre - shapes which define the same shape .
consider two ordered tree - shapes with collapsed edges .
replace their binary representations by collapsed representations , where the zero attributed edges have been removed .
the orders of the original trees induce well - defined orders on the collapsed trees .
we say that two ordered tree - shapes are _ the same _ when their collapsed ordered , attributed versions are identical , as in fig .
[ constedge ] .
tree identifications come with an inherent bijection of subsets of the edge set @xmath40 : if we identify @xmath45 , denote by @xmath46 the sets of non - collapsed edges with non - zero attributes .
the identification of @xmath16 and @xmath29 is equivalent to an order preserving bijection @xmath47 , identifying those edges that correspond to the same edge in the collapsed tree - shape .
varying the attributes @xmath43 , @xmath48 spans a family of tree - shapes with fixed topology and several representatives .
thus , the edge sets @xmath49 and @xmath50 induce linear subspaces @xmath51 of @xmath9 where , except for on the axes , the topological tree structure is constant .
the tree - shapes represented in @xmath52 are exactly the same as those represented in @xmath53 .
the bijection @xmath48 induces a bijection @xmath54 given by @xmath55 , which connects each representation @xmath56 to the representation @xmath57 of the same shape .
note that the @xmath58 are spanned by axes in @xmath9 .
define a map @xmath59 for each pair of identified tree - structures , and form an equivalence on @xmath9 by setting @xmath60 for all @xmath16 and @xmath59 . for each @xmath61
, @xmath62 is the equivalence class @xmath63 .
the quotient space @xmath64 of equivalence classes @xmath62 is the space of ordered tree - like shapes .
quotient spaces are standard constructions from topology and geometry , where they are used to glue spaces together  @xcite .
the geometric interpretation of the identification in the tree - space quotient is that we fold and glue the pre - shape space space along the identified subspaces ; i.e. , when @xmath65 , we glue the two points @xmath5 and @xmath6 together .
see fig .
[ folding ] for an illustration .      given a metric @xmath4 on the euclidean pre - shape - space @xmath42
, we induce the standard quotient pseudometric @xcite @xmath66 on the quotient space @xmath67 by setting @xmath68 this corresponds to finding the optimal path from @xmath62 to @xmath69 , consisting of any number @xmath70 of concatenated euclidean lines , passing through @xmath71 identified subspaces , as shown in fig .
[ folding ] .
it is clear from the definition that the distance function @xmath66 is symmetric and transitive .
it is , however , an infimum , giving a risk that the distance between two distinct tree - shapes is zero , as occurs with some intuitive shape distance functions  @xcite .
this is why @xmath66 is called a _
_ pseudo__metric , and it remains to prove that it actually is a metric ; i.e. , that @xmath72 implies @xmath73 .
we prove this for two specific metrics on @xmath9 , which come from two different ways of combining individual edge distances : the metrics @xmath74 and @xmath75 on @xmath42 are the norms @xmath76    from now on , @xmath4 and @xmath66 will denote either the distance functions @xmath74 and @xmath77 , or @xmath75 and @xmath78 .
we prove the following theorem in section  [ theoremproof ] :    [ orderedthm ] the distance function @xmath66 is a metric on @xmath38 , which is a contractible , complete , proper geodesic space .
thus , given any two trees , we can always find a geodesic between them in both metrics @xmath77 and @xmath78 .
on @xmath9 , the induced pseudometric @xmath66 on @xmath38 is a metric . ]
we may often want to restrict to a subset of the large tree - space .
[ subspacedef ] consider a subset @xmath10 , which only contains all representations of trees of certain restricted topologies , defined by collapsed subtrees of the maximal tree @xmath15 .
the @xmath79 collapsed subtree of @xmath15 is characterized by a subset @xmath80 consisting of the edges in the maximal tree @xmath15 which are not collapsed .
associated to it is a linear subspace @xmath81 containing representations of all the trees of this particular topology .
we include all representations of each tree topology , and obtain a restricted preshape space @xmath82 containing all the trees that have of one of the considered topologies .
the equivalence relation @xmath83 on @xmath9 restricts to an equivalence relation @xmath84 on @xmath11 , from which we obtain a restricted tree - shape space @xmath85 .
the metric @xmath4 on @xmath9 induces a metric @xmath86 on @xmath11 which induces a quotient pseudometric @xmath87 on @xmath88 .
denote by @xmath11 the space of all trees in @xmath9 with @xmath27 leaves , now @xmath88 is the space of tree - shapes with @xmath27 leaves .
note that the space of tree - shapes on @xmath27 leaves in _
i ) _ is different from the billera - holmes - vogtmann ( bhv ) space @xcite of trees with vector attributes , because in the bhv space , geodesics will always deform leaves onto leaves , whereas in @xmath88 , leaves can be transformed to non - leaf branches by a geodesic .    even in the restricted tree - shape space ,
we obtain an induced metric :    [ subspacemetric ] the pseudometric @xmath89 on @xmath88 is a metric , and @xmath90 a contractible , complete , proper metric space .
first , we show that the pseudometric is a metric .
the pseudometric in equation   defines the distance @xmath91 as the infimum of lengths of paths in @xmath38 connecting @xmath62 and @xmath69 .
any path in @xmath88 is also a path in @xmath38 , so if @xmath92 , then @xmath72 as well , so @xmath73 .
the proofs of the other claims follow the proof of theorem  [ orderedthm ] as in section  [ theoremproof ] .
the world is not two - dimensional , and for most applications it is necessary to study embedded trees in @xmath13 . the main difference from the ordered case is that trees in @xmath13 have no canonical edge order .
the left - right order on children of planar trees gives an implicit preference for edge matchings , and hence reduces the number of possible matches .
when we no longer have this preference , we consider all orderings of the same tree and choose orders which minimize the distance .
we define the space of ( unordered ) tree - like shapes in @xmath8 as the quotient @xmath93 , where @xmath94 is the group of reorderings of the maximal binary tree @xmath15 .
the metric @xmath66 on @xmath38 induces a quotient pseudometric @xmath95 on @xmath96 .
again , we can prove :    [ unorderedthm ] for @xmath95 induced by either @xmath77 or @xmath78 , the function @xmath95 is a metric and the space @xmath97 is a contractible , complete , proper geodesic space .
the same result holds for restricted tree - spaces with several restricted tree topologies : let @xmath10 be a subspace containing only trees of certain restricted topologies , as in definition  [ subspacedef ] , which is saturated with respect to the reordering group is saturated if , for each tree topology appearing in @xmath11 , all reorderings of the same tree topology also appear in @xmath11 .
equivalently , @xmath98 , where @xmath99 @xmath94 . for the corresponding restricted tree - space @xmath100 ,
the quotient pseudometric @xmath101 is a metric and the space @xmath102 is a contractible , complete , proper geodesic space .
note that @xmath94 is a finite group , which means that @xmath96 is locally well - behaved almost everywhere .
in particular , off fixed - points for the action of reorderings @xmath103 on @xmath38 , the projection @xmath104 is a local isometry , i.e. , it is distance preserving within a neighborhood . hence , the geometry from @xmath38 is preserved off the fixed points .
geometrically , a fixed point in @xmath38 is an ordered tree - shape where a reordering @xmath105 of certain branches does not change the ordered tree - shape ; that is , some pair of sibling edges must have the same shape attributes .
in particular , the fixed points are non - generic because they belong to the lower - dimensional subset of @xmath38 where two sibling edges have identical shape .
theorem  [ unorderedthm ] can be proved using standard results on compact transformation groups along with similar techniques as for theorem  [ orderedthm ] .
while considering all different possible orderings of the tree is easy from the point of view of geometric analysis , in reality this becomes a computationally impossible task when the size of the trees grow beyond a few generations .
in real applications we can , however , efficiently reduce complexity using heuristics and approximations , as discussed in section  [ complexitysection ] .
it follows from the definition that the metrics @xmath77 and @xmath106 coincide with the classical tree edit distance ( ted ) metric for ordered and unordered trees , respectively . in this way
the abstract , geometric construction of tree - space gives a new way of viewing the intuitive ted algorithm .    the metrics @xmath78 and @xmath107 are descents of the euclidean metric on @xmath38 , and geodesics in this metric are concatenations of straight lines in flat regions . in section
[ fundamental ] we compare the two metrics using examples .
we now pass to the proof of theorem  [ orderedthm ] .
the rest of the article is independent of this section , and during the first read , the impatient reader may skip to section  [ curvaturesection ] .
however , while the proof is technical , theorem  [ orderedthm ] is a fundamental building block for the shape space framework .
we shall assume that the reader has a good knowledge of metric geometry or general topology @xcite .
it is crucial for the proof that we are only identifying subspaces of the euclidean space @xmath9 which are spanned by euclidean axes , and these are finite in number .
this induces a well - behaved projection @xmath108 , which carries many properties from @xmath9 to @xmath38 .
we say that ordered tree - shapes whose ( collapsed ) ordered structure is the same , belong to the same _ combinatorial tree - shape type_. for each combinatorial type of ordered tree - shape @xmath109 ( @xmath110 ) which can be represented by collapsing edges in the maximal tree @xmath111 , there is a family @xmath112 of subsets of @xmath40 , which induce that particular type @xmath109 when we endow the edges in @xmath112 ( @xmath113 ) with nonzero attributes and leave all other edges with zero attributes .
these subsets are characterized by the properties    * the cardinality @xmath114 for all @xmath115 , @xmath110 .
* there is a depth - first order on each @xmath112 induced by the depth - first order on @xmath40 , such that the ordered , combinatorial structure defined by any @xmath112 coincides with that defined by @xmath116 .
that is , the subset @xmath112 for any @xmath117 lists the set of edges in @xmath15 which have nonzero attributes for the @xmath79 representation of any shape of type @xmath109 .
corresponding to each @xmath112 is the linear subspace @xmath118 of @xmath9 given by @xmath119 and by condition b ) we can define isometries @xmath120 by forgetting the zero entries in @xmath118 and keeping the depth - first coordinate order .
we generate the equivalence @xmath83 on @xmath9 by asking that @xmath121 whenever @xmath122 for some @xmath123 .
we now define the space of ordered tree - like shapes as the quotient @xmath67 , and define the quotient map @xmath108 .
it is clear from the definition that the distance function @xmath66 defined in is symmetric and satisfies the triangle inequality , which makes it a _
pseudometric_.    [ pseudometricismetric ] let @xmath4 denote @xmath74 or @xmath75 .
the pseudometric @xmath66 is a metric on @xmath38 .
it suffices to show that @xmath124 implies @xmath73 ( @xmath125 ) .
moreover , it is also easy to show that @xmath126 for any @xmath127 , so it suffices to show that @xmath128 implies @xmath73 .
hence , from now on , write @xmath66 for @xmath78 , and assume that @xmath72 for two tree - shapes @xmath62 and @xmath69 .    choose @xmath129 such that @xmath130 that is , @xmath131 is smaller than the size of any of the non - zero edges in @xmath62 and @xmath69 .
we may assume that @xmath132 since otherwise we may assume by symmetry that @xmath133 and @xmath134 .
denote by @xmath135 the image of @xmath118 under the quotient projection @xmath108 for any @xmath117 .
we may assume that @xmath62 and @xmath69 belong to the same identified subspace ; that is , there exist @xmath136 such that @xmath137 since otherwise , @xmath138 since @xmath69 is a finite set , and @xmath139 is a closed set , ( [ emptyint ] ) implies @xmath140 in this case , the path will have to go through some @xmath141 which does not contain points equivalent to @xmath29 , and @xmath142 since in order to reach @xmath143 , we need to remove edge attributes which are nonzero in @xmath69 , and @xmath144 for all @xmath145 .
thus , eq .  [ inthesame ] holds , and in fact , it holds for all the intermediate path points @xmath146 from eq .
[ metricdefn ] .
but if the path points stay in @xmath135 , then the path consists of shifting and changing the nonzero edge attributes of the trees in question .
this will only give a sum @xmath147 if the trees are identical and the path is constant .
here , we prove the rest of theorem  [ orderedthm ] , namely that the tree - shape space @xmath148 is a complete , proper geodesic space , and @xmath38 is contractible .
first , we note that although @xmath38 is not a vector space , there is a well - defined notion of size for elements of @xmath38 , induced by the norm on @xmath9 :    [ sizelemma ] note that if @xmath149 , we must have @xmath150 ; hence we can define @xmath151 .
the equivalence is generated recursively from the conditions @xmath149 whenever either @xmath152 , indicating @xmath153 ; or @xmath154 , indicating @xmath155 since the @xmath156 are isometries .
hence , the lemma holds by recursion .
we will prove that @xmath148 is a proper geodesic space using the hopf - rinow theorem for metric spaces @xcite , which states that every complete locally compact length space is a proper geodesic space .
a length space is a metric space in which the distance between two points can always be realized as the infimum of lengths of paths joining the two points .
note that this is a weaker property than being a geodesic space , as the geodesic joining two points does not have to exist ; it is enough to have paths that are arbitrarily close to being a geodesic .
it follows from ( * ? ? ?
* lemma 5.20 ) that @xmath148 is a length space for _ any _ metric @xmath4 on @xmath9 where @xmath66 is a metric .    to see that the tree - shape space is locally compact ,
note that the projection @xmath108 is finite - to - one , so any open subset @xmath157 of @xmath38 has as pre - image a finite union @xmath158 of open subsets of @xmath9 , such that @xmath159 and @xmath160 is compact whenever @xmath157 is bounded .
we also need to prove that @xmath148 is complete :    [ completenessdescends ] let @xmath66 denote either of the metrics @xmath77 and @xmath78 .
the shape space @xmath148 is complete .
the proof needs a lemma from general topology :    _ ( * ? ? ?
* , theorem  2.3 ) _ [ duglemma ] let @xmath161 be a metric space and assume that the metric @xmath4 has the following property : _ there exists @xmath129 such that for all @xmath162 the closed ball @xmath163 is compact .
_ then @xmath66 is complete .    using the projection @xmath108
, we can prove :    [ closedandbounded ] bounded closed subsets of @xmath38 are compact .
since lemma  [ sizelemma ] defines a notion of size in @xmath38 , any closed , bounded subspace @xmath164 in @xmath38 is contained in a closed ball @xmath165 in @xmath38 for some @xmath166 , where @xmath167 is the image @xmath168 . since @xmath169 , it follows that @xmath170 , which is a closed and bounded ball in @xmath9 . since closed , bounded subsets of @xmath9 are compact @xmath171 is compact . by continuity of @xmath172 , @xmath173 is compact . then @xmath164 is compact too .
it is now very easy to prove proposition  [ completenessdescends ] :    by lemma  [ closedandbounded ] , all closed and bounded subsets of @xmath38 are compact , but then by lemma  [ duglemma ] the metric @xmath66 must be complete .    using the hopf - rinow theorem (
* , proposition  3.7 ) we thus prove that @xmath148 is a complete , proper geodesic space .
we still miss contractibility :    [ contractible ] let @xmath174 be a normed vector space and let @xmath83 be an equivalence on @xmath174 such that @xmath175 implies @xmath176 for all @xmath177
. then @xmath178 is contractible .
define a map @xmath179 \to \bar{b}$ ] by setting @xmath180 .
now @xmath181 is well defined because of the condition on @xmath83 , and @xmath182 so @xmath181 is a homotopy from @xmath183 to the constant zero map .    combining the results of section  [ theoremproof ]
, we see that the proof of theorem  [ orderedthm ] is complete .
having proved theorem  [ orderedthm ] , we may now pass to studying the geometry of the tree - shape space through its geodesics .
uniqueness of geodesics and means is closely connected to the geometric notion of _ curvature _ , a concept which fundamentally depends on the underlying metric . using methods from metric geometry @xcite we shall investigate the curvature of the tree - shape space with the qed and ted metrics . using curvature ,
we obtain well - posed statistical methods for qed .
the next theorem states that in the tree - shape space endowed with the qed metric , any randomly selected point has a corresponding neighborhood within which the tree - space has non - positive curvature .
we shall use this fact to show that datasets within that same neighborhood have unique averages .
[ qedcurv ]    * endow @xmath38 with the qed metric @xmath78 . a generic point
@xmath184 has a neighborhood @xmath185 in which the curvature is non - positive . at non - generic points ,
the curvature of @xmath186 is @xmath187 , or unbounded from above . *
endow @xmath38 with the ted metric @xmath77 .
the metric space @xmath188 does not have locally unique geodesics anywhere , and the curvature of @xmath188 is @xmath187 everywhere .
claims i ) and ii ) also hold in the subspace @xmath189 containing only trees of certain restricted topologies , as defined in definition  [ subspacedef ] .    here
, local uniqueness is defined as uniqueness within a sufficiently small neighborhood .
_ genericity _ is a key concept in this paper .
many of our results , e.g. , uniqueness of means , do not hold in general , but they do hold for a randomly chosen dataset with respect to natural probability measures .    a _ generic property _ in a metric space @xmath190 is a property which holds on an open , dense subset of @xmath9 .    in the tree - spaces @xmath191 and @xmath192 , one interpretation is that generic properties hold almost surely , or with probability one , with respect to natural probability measures .
thus , for a random tree - shape , we can safely assume that it satisfies generic properties , e.g. , that the tree - shape is a binary tree .
non - generic property _ is a property whose  not happening  is generic .
this is similarly interpreted as a property that may _ not _ hold for randomly selected tree - shapes .
a detailed discussion of the relation between genericity and probability is found in appendix a.    one common misconception is that the term  generic tree  refers to a particular class of trees with a particular generic property .
it is important to note that many different properties , which do not necessarily happen on the same subsets of tree - space , may all be generic at the same time .
however , any finite set of generic properties _ will _ all happen on an open , dense subset .    [ generic ]
tree - shapes that are truly binary ( i.e.  their internal edges are not collapsed ) are generic in the space of all tree - like shapes .
let @xmath193 be a tree - shape in @xmath38 or @xmath96 which is not truly binary , represented by a maximal binary tree @xmath15 . by adding arbitrarily small noise to the zero attributes on edges of @xmath15
, we obtain truly binary tree - shapes @xmath194 which are arbitrarily close to @xmath193 .
thus , the set of full truly binary tree - shapes in @xmath38 or @xmath96 is open and dense .
hence , truly binary tree - shapes are generic both in @xmath38 and in @xmath96
.     goes through a tree with a trifurcation , while geodesic @xmath195 does not have internal structural transitions . ]
the essence of the proposition is that binary tree - shapes are generic , but that does not mean that non - binary trees do not need to be considered ! while non - binary trees may not appear as randomly selected trees , they _ do _ appear in geodesics between randomly selected pairs of trees , as in fig .
[ fundamentalfigure ] .
non - binary tree - like shapes also appear as samples in real - life applications , e.g. , when studying airway trees .
however , we interpret this as an artifact of resolution rather than true higher - degree vertices .
for instance , airway extraction algorithms record trifurcations when the lengths of internal edges are below certain threshold values .      in order to understand and prove theorem  [ qedcurv ] , we need a definition of curvature in metric spaces . in spite of its simplicity and elegance ,
this concept from metric geometry is novel in computer vision .
we shall spend a little time introducing it before proceeding to prove theorem  [ qedcurv ] in section  [ qedcurvproof ] .
since general metric spaces can have all kinds of anomalies , the concept of curvature in such spaces is defined through a comparison with spaces that are well understood .
more precisely , the metric spaces are studied using _ geodesic triangles _ , which are compared with corresponding _ comparison triangles _ in model spaces with a fixed curvature @xmath196 .
the model spaces are spheres ( @xmath197 ) , the plane @xmath12 ( @xmath198 ) and hyperbolic spaces ( @xmath199 ) , and through comparison with these spaces , we can bound the curvature of the metric space by @xmath196 . in this paper we shall use comparison with planar triangles , which gives us curvature bounded from above by @xmath200 .     space if , for a geodesic triangle @xmath201 and for any point @xmath16 on the triangle , the distance from @xmath16 to the opposite vertex is not longer than the corresponding distance in the planar comparison triangle @xmath202 . ]    given a geodesic metric space @xmath203 , a _
geodesic triangle _
@xmath201 in @xmath203 consists of three points @xmath204 and geodesic segments joining them . a planar _ comparison triangle _ @xmath205 for the triangle @xmath201 consists of three points @xmath206 in the plane , such that the lengths of the sides in @xmath202 are the same as the lengths of the sides in @xmath201 , see fig .
[ cat0 ] .
a @xmath207 space is a metric space in which geodesic triangles are  thinner  than for their comparison triangles in the plane .
that is , @xmath208 for any @xmath16 on the edge @xmath209 where @xmath210 is the unique point on the edge @xmath211 such that @xmath212 and @xmath213 .
if the planar comparison triangle is replaced by a comparison triangle in the sphere or hyperbolic space of fixed curvature @xmath196 , we get a @xmath214 space .
a space @xmath203 has non - positive curvature if it is locally @xmath207 , i.e. , if any point @xmath215 has a radius @xmath20 such that the ball @xmath216 is @xmath207 .
similarly , define curvature bounded by @xmath196 as being locally @xmath214 .
[ negcurvex ]    * the space @xmath157 obtained by gluing a family euclidean spaces @xmath217 together along isomorphic affine subspaces @xmath218 is a @xmath207 space . at any point in @xmath157 which is not a glued point ,
the local curvature is @xmath200 , since the space is locally isomorphic to the corresponding @xmath217 . at any glued point
, it can be shown that the local curvature is @xmath219 . * the gpca construction by vidal et al .
@xcite defines a @xmath207 space , giving a potential use of @xmath207 spaces and metric geometry in machine learning .
* the space of phylogenetic trees is a @xmath207 space  @xcite . *
as we are about to see , the space of tree - like shapes is locally a @xmath207 space almost everywhere .
one of the main reasons why @xmath214 spaces ( and @xmath207 in particular ) are attractive , is due to the following result on existence and uniqueness of geodesics .    _
* proposition ii 1.4 ) _ [ bhprop ] let @xmath220 be a @xmath214 space . if @xmath221 , then all pairs of points have a unique geodesic joining them
. for @xmath197 , the same holds for pairs of points at a distance less than @xmath222 .
more results on curvature in metric spaces can be found in the book by bridson and haefliger @xcite .      in this section
we study the curvature of tree - shape space using the theory of @xmath207 spaces .
we show that at a generic tree , the shape space has bounded curvature .
the results rest on the following theorem :    [ unique_geo ] at a generic point @xmath184 , the shape space is locally @xmath207 , and thus , @xmath38 has locally unique geodesics in a neighborhood of @xmath62 .
recall from section  [ singularspace ] how @xmath38 was formed by identifying subspaces @xmath223 , defined in eq .
[ vdef1 ] and  [ vdef2 ] .
these identified subspaces corresponded to different representations in @xmath9 of the same shape @xmath184 .
the points in @xmath38 can now be divided into three categories :    * points @xmath224 which do not belong to the image of an identified subspace because they only have one representative in @xmath9 ,    and two classes of points in @xmath38 which have more than one representative in @xmath38 .    *
the first class contains points @xmath225 at which the space @xmath38 is locally homeomorphic to an intersection of linear spaces , as in example  [ negcurvex ] a ) .
these points are images of points @xmath226 which belong to one single identified subspace @xmath58 .
* the second class contains points @xmath227 whose preimages @xmath228 in @xmath9 are at the intersection of identified subspaces @xmath229 .
an example of such points is the image of the origin in fig .
[ folding ] .
these points correspond to trees where , infinitely close to the same tree , we can find pairs of trees in @xmath38 between which geodesics are not unique .
these three classes of points correspond to local curvature @xmath200 , @xmath219 and @xmath187 .
that is , the space is locally @xmath207 at points in categories _ i ) _ ; at points from _ ii ) _ it is @xmath214 for every @xmath230 , so has curvature @xmath219 ; and at points from _ iii ) _ it is not @xmath214 for any @xmath230 ; hence the curvature is @xmath187 .
it thus suffices to show that the points in category _
iii ) _ are non - generic , which follows easily from the fact that these must necessarily sit in a lower - dimensional subspace of @xmath38 .
the proof carries over to the subspace @xmath88 .
we call a @xmath207 neighborhood @xmath231 of a point @xmath184 an _ injectivity neighborhood _ of @xmath62 .    based on the above
, we are now ready to prove :    * the qed case : since @xmath38 is locally @xmath207 at generic points @xmath62 , the curvature of @xmath38 is non - positive in a neighborhood @xmath157 of @xmath62 . at points
@xmath232 , however , we will always find pairs of points @xmath233 arbitrarily close to @xmath16 with two geodesics joining them , just as in fig .
[ folding ] . * the ted case : consider a tree - shape @xmath234 , represented by a point @xmath61 .
induce a second tree - shape @xmath194 represented by @xmath235 , where @xmath236 such that @xmath237 and @xmath238 have one non - zero coordinate , found in different edges , which are both nonzero edges in @xmath16 .
the topology of @xmath194 is the same as of @xmath193 . for any @xmath239
, we can find @xmath27 ted geodesics @xmath240 from @xmath193 to @xmath194 , where @xmath241 can be decomposed as @xmath242 .
thus , there are infinitely many ted geodesics from @xmath193 to @xmath194 , and @xmath188 does not have locally unique geodesics anywhere . as a consequence ,
its curvature is unbounded everywhere ( * ? ? ?
* proposition ii 1.4 ) .
the practical meaning of theorem  [ qedcurv ] is that a ) we can use techniques from metric geometry to search for qed averages , b ) as we are about to see , for datasets contained in an injectivity neighborhood , there exist unique means , centroids and circumcenters for the qed metric , and c ) the same techniques can not be used to prove existence or uniqueness of prototypes for the ted metric , even if they were to exist .
in fact , any geometric method which requires bounded curvature  @xcite will fail for the ted metric .
_ this motivates our study of the qed metric . _
it is easy to prove that the same results also hold for unordered tree - shapes :    [ unordered_curvature ] the space @xmath243 of unordered trees with the qed metric is generically non - positively curved . with the ted metric @xmath106 , however , @xmath96 has everywhere unbounded curvature , geodesics are nowhere locally unique and neither are any of the types of average tree discussed in this paper .
the same holds in the subspace @xmath244 , defined in theorem  [ unorderedthm ] .      in this section
we use what we learned in the previous section to show that , given the qed metric on a space of tree - like shapes , we can find various forms of average shape in the space of ordered tree - like shapes , assuming that the data lie within an injectivity neighborhood .
there are many competing ways of defining central elements given a subset of a metric space .
we discuss several : the _ circumcenter _ considered in @xcite , the _ centroid _ considered , among other places , in @xcite , and the _ mean _ @xcite .
the problem of existence and uniqueness of averages can be attacked using convex functions .
recall that a function @xmath245 \to { \mathbb{r}}$ ] is convex if @xmath246 for all @xmath247 $ ] and @xmath248 $ ] .
if we can replace @xmath249 with @xmath250 whenever @xmath2510 , 1[$ ] , then @xmath252 is _ strictly _ convex .
convex functions have minimizers , which are unique for strictly convex functions .
hence , existence and uniqueness of averages can be proven by expressing them as minimizers of strictly convex functions .
we say that a function @xmath253 on a geodesic metric space @xmath9 is ( strictly ) convex if for any two points @xmath254 and any geodesic @xmath255 \to x$ ] from @xmath16 to @xmath29 , the function @xmath256 is ( strictly ) convex .
we shall make use of the following standard properties of convex functions :    [ convexlemma ]    * if @xmath257 and @xmath258 are both convex , @xmath105 is monotonous and increasing , and @xmath105 is strictly convex , then @xmath259 is strictly convex . * if @xmath257 and @xmath258 are both convex , then @xmath260 is also convex .
if either @xmath252 or @xmath105 is strictly convex , then @xmath261 is strictly convex as well .
the _ mean _ of a finite subset @xmath262 in a metric space @xmath190 is defined as in eq .
[ meandef ] , and is called the _ frchet mean_. local minimizers of eq .
[ meandef ] are called _
karcher means_.    the following result follows from a more general theorem by sturm  ( * ? ? ?
* proposition 4.3 ) ; we include the basic version of the proof here for completeness .
[ existencemeans ] means exist and are unique in @xmath207-spaces .
the function @xmath263 given by @xmath264 is convex for any fixed @xmath162 by ( * ? ? ?
* proposition ii.2.2 ) , so the function @xmath265 is _ strictly _ convex by lemma  [ convexlemma ] i ) .
but then @xmath266 is strictly convex by lemma  [ convexlemma ] _ ii ) _ , and a mean is just a minimizer of the function @xmath267 .
the function @xmath267 is coercive , so the minimizer exists .
since @xmath267 is strictly convex , the minimizer is unique .
we also consider two other types of statistical  prototypes  for a dataset , namely _
circumcenters _ and _ centroids_. these are both well - known in the context of metric geometry and @xmath214 spaces .
* * circumcenters . *
consider a metric space @xmath220 and a bounded subset @xmath268 .
there exists a unique smallest closed ball @xmath269 in @xmath203 which contains @xmath11 ; the center @xmath270 of this ball is the _ circumcenter _ of @xmath11 .
* * the centroid of a finite set . *
let @xmath9 be a uniquely geodesic metric space ( a metric space where any two points are joined by a unique geodesic ) .
the centroid of a set @xmath271 of @xmath27 elements is defined recursively as a function of the centroids of subsets with @xmath272 elements as follows : denote the elements of @xmath273 by @xmath274 . if @xmath273 contains two elements , @xmath275 ,
the centroid @xmath276 of @xmath273 is the midpoint of the geodesic joining @xmath277 and @xmath278 . if @xmath279 , define @xmath280 , which is a set with @xmath27 elements .
similarly , for larger @xmath70 , @xmath281 .
all these sets have @xmath27 elements .
if the elements of @xmath282 converge to a point @xmath283 as @xmath284 , then we say that @xmath285 is the _ centroid _ of @xmath273 in @xmath9 .
based on the theory of @xmath214 spaces and our results for means , we have for the set of tree - like shapes :    [ all_averages ] endow @xmath38 with the qed metric @xmath78 . a generic point
@xmath184 has a neighborhood @xmath157 such that sets contained in @xmath157 have unique means , centroids and circumcenters .
_ the same statistical properties also hold for the qed metric on unordered tree - shapes : _ generic points in the space of unordered tree - shapes with the qed metric @xmath243 have neighborhoods within which means , circumcenters and centroids exist and are unique .    for the ted metric ,
these are not unique .
the same results hold in the restricted tree - spaces @xmath88 and @xmath192 , defined in definition  [ subspacedef ] and theorem  [ unorderedthm ] .
first consider @xmath38 and @xmath96 with the qed metric . by theorems  [ qedcurv ] and  [ unordered_curvature ] , @xmath38 and @xmath96 are both locally @xmath207 spaces , and by theorems  [ orderedthm ] and  [ unorderedthm ] they are both complete metric spaces .
we have seen in theorem  [ existencemeans ] that means exist and are unique in @xmath207 spaces , so the statement holds for means . by (
* proposition  2.7 ) , any subset @xmath203 of a complete @xmath207 space has a unique circumcenter .
hence , the statement holds for circumcenters .
similarly , by ( * ? ? ?
* theorem  4.1 ) , finite subsets of @xmath207 spaces @xmath9 have centroids ( unique by definition ) , so the statement holds for centroids .
we turn to the ted metric . by definition , for any @xmath195-point dataset
, all these notions of mean reduce to finding the midpoint of a geodesic connecting the two points .
we know that geodesics and midpoints are not unique in the ted metric .
this ends the proof .
we have shown that the local curvature is nonpositive almost everywhere in @xmath38 , which makes @xmath38 well suited for geometric definitions of statistical properties .
however , our notion of  almost everywhere  is strongly tied to ( maximal ) dimensionality , which again is strongly tied to the topological structure of the maximal tree @xmath15 .
one consequence is that the injectivity neighborhoods in @xmath38 are rather small , as we are about to see through examples . in this section
we impose natural constraints on tree - space that allow us to increase the size of the injectivity neighborhoods , and make a conjecture for future expansion beyond the use of @xmath207-spaces .
consider the following two examples ; we thank the anonymous reviewer for the first !    * consider the tree - shapes @xmath286 and @xmath287 shown in fig .
[ ref_ex_1 ] , left .
these two tree - shapes are joined by two geodesics , and thus @xmath286 and @xmath287 are not contained in the same injectivity neighborhood in @xmath38 . however , in a suitably chosen @xmath88 , they can be . *
consider the tree - shape @xmath193 in the space of unordered tree - shapes with attributes in @xmath12 , spanned by the maximal tree @xmath15 as in fig .
[ ref_ex_2 ] , right . arbitrarily close to @xmath193 we will find two trees @xmath286 and @xmath287 which are joined by two geodesics , as shown in the figure .    .
]     are two other trees @xmath286 and @xmath287 who can not be joined by a unique geodesic . ]
as a illustrated by these examples , the @xmath207 injectivity neighborhoods in the shape - space @xmath38 can be very small , mainly containing trees whose topology is the same as @xmath15 .
however , we can obtain much larger injectivity neighborhoods by restricting to the natural subspaces @xmath189 and @xmath244 as in definition  [ subspacedef ] . as shown in theorem  [ all_averages ] , @xmath88 and @xmath192 have the same nice geometric properties as @xmath38 and @xmath96 , and @xmath11 can be chosen so that the injectivity neighborhoods are bigger than in @xmath38 and @xmath96 by avoiding situations as in the examples above .
radius is not a good measure for the size of an injectivity neighborhood , as a tree may contain both small branches , which do not have much room to vary , as well as large branches , which will be allowed to move more throughout such a neighborhood .
however , any convex neighborhood which does not contain points of curvature @xmath288 , will be an injectivity neighborhood .
all the results from section  [ meansection ] hold at generic points , within an injectivity neighborhood where the @xmath207 property holds .
we have seen examples of points where local @xmath207-property must fail , illustrating the limitaitons of @xmath207 techniques for analyzing general trees .
however , most of the situations where the @xmath207 property fails are highly non - generic , and we conjecture that more general results can be proven :    [ conjecture ] for a generic set of points @xmath289 in @xmath38 , @xmath96 , @xmath88 or @xmath192 , means exist and are unique .      as we have seen in theorems  [ qedcurv ] , the qed metric gives locally non - positive curvature at generic points , while the ted metric gives unbounded curvature everywhere on @xmath191 and @xmath192 .
equivalently , geodesics are locally unique almost everywhere in the qed metric , while nowhere locally unique in the ted metric . as emphasized by theorem  [ all_averages ] , this means that we can not imitate the classical statistical procedures on shape spaces using the ted metric , while for the qed metric , we can .    note , moreover , that the qed metric is the quotient metric induced from the euclidean metric on the pre - shape space @xmath9 , making it the natural choice of metric seen from the shape space point of view .    from a computational point of view , the ted metric has nice local - to - global properties .
if the trees @xmath286 and @xmath287 are decomposed into subtrees @xmath290 and @xmath291 as in fig
.  [ tedsplitting ] , such that the geodesic from @xmath286 to @xmath287 restricts to geodesics between @xmath292 and @xmath293 as well as @xmath294 and @xmath295 , then @xmath296 . many dynamic programming algorithms for ted use this property , and the same does not hold for the qed metric , due to the square root .    for a qualitative comparison of qed and ted , we compare the geodesics defined by the ted and qed metrics between small , simple trees .
consider the two tree - paths in fig .
[ tedqedcomparison ] , where the edges are endowed with scalar attributes @xmath297 describing edge length . computing the costs of the two different paths in both metrics , we find the shortest ( geodesic ) path .    path @xmath298 indicates a matching left and right side edges @xmath299 and @xmath4 , while path @xmath195 does not make the match .
the cost of path @xmath298 is @xmath300 in both metrics , while the cost of path @xmath195 is @xmath301 in the qed metric and @xmath302 in the ted metric .
thus , ted will identify the @xmath299 and @xmath4 edges whenever @xmath303 , while qed makes the identification whenever @xmath304 .
thus , ted will be more prone to internal structural change than qed .
the same occurs in the comparison of ted and qed matching in figs .  [ qedmatching ] and  [ tedmatching ] .
although the ted is more prone to matching trees with different tree - topological structures , the edge matching results are similar , as is expected , since the metrics are closely related .
in general , computational complexity is a problem for both ted and qed . computing ted distances between unordered trees is np - complete @xcite , and we conjecture that the qed metric is np - complete as well .
we can , however , often use geometry and prior knowledge ( e.g. , anatomy ) to find efficient approximations .
_ trees appearing in applications are often not completely unordered , but are semi - labeled_.    [ semilabel ] most airway trees have similar , but not necessarily identical , topological structure , where several branches have names and can be identified by experts .
the top generations of the airway tree serve very clear purposes in terms of anatomy .
the root edge is the trachea ; the second generation edges are the left and right main bronchi ; the third generation edges lead to the lung lobes .
as these are easily identified , we find a semi - labeling of the airway tree , and use it to simplify computations of inter - airway geodesics in section  [ pulmonarysection ] .
since the decomposition strategy used for dynamic programming in ted is not available for qed , an approximation of qed is used in our experiments .
many anatomical trees have a somewhat fixed overall structure . for these , it is safe to assume that the number of internal structural transitions found in a geodesic deformation is low , and that the geodesics pass through identified subspaces of low codimension . the latter assumption is equivalent to assuming that the trees appearing throughout the geodesic deformation have nodes of low degree . for instance , for the airway trees studied in section  [ pulmonarysection ] below , we find empirically that it is enough to allow for one structural change in each lobar subtree , which has at most a trifurcation .
recall the definition of the metric from eq .
[ metricdefn ] ; the approximation consists of imposing upper bounds @xmath305 on the number @xmath70 and @xmath267 on the degrees of internal vertices appearing in eq .
[ metricdefn ] , respectively , giving : @xmath306 where all @xmath307 and @xmath308 have vertex degrees at most @xmath267 .
geometrically , @xmath70 is the number of euclidean segments concatenated to form the geodesic .
bounding @xmath70 is equivalent to bounding the number of internal topological transitions throughout the geodesic .
in fact , @xmath309 _ the number of internal topological transitions in the geodesic_.    all edges are translated to start at @xmath310 , and represented by a fixed number of landmark points ( in our case @xmath311 ) evenly distributed along the edge , the first at the origin .
the distance between two edge attributes @xmath312 is the euclidean distance @xmath313 .
we approximate of the qed metric using algorithm  [ planaralg ] ; see appendix b in the supplemental material for details .
the complexity of algorithm 1 is @xmath314 where @xmath27 is the number of internal vertices , @xmath305 is the bound on @xmath70 , @xmath267 is the bound on vertex degree and @xmath315 is the optimization in line @xmath316 . for the unordered airway trees in section  [ pulmonarysection ] , we combine algorithm 1 with a complete search through the set of branch orderings . computing qed distances through a complete search is not optimal , and finding more exact and efficient algorithms is a nontrivial research problem .
@xmath16 , @xmath29 planar rooted depth @xmath27 binary trees @xmath317 set of ordered identified pairs @xmath318 of subspaces of @xmath9 corresponding to internal topological changes through trees of order at most @xmath267 , corresponding to a subspace @xmath273 of @xmath38 , s.t .  if @xmath319 , then also @xmath320 .
@xmath321 @xmath322 @xmath323 @xmath324 @xmath325 @xmath326 geodesic @xmath327    [ planaralg ]
the qed metric is new , whereas the properties of the ted metric are well known @xcite .
our experimental results on real and synthetic data illustrate the geometric properties of the qed metric .
the experiments on airway trees in section  [ pulmonarysection ] show , in particular , that it is feasible to compute geodesics between real , @xmath8 data trees .
movies illustrating geodesics between planar depth @xmath26 trees , as well as a table illustrating a tree - shape matching experiment for a set of synthetic planar depth @xmath26 trees , are found on the web page http://image.diku.dk/aasa/tree_shape/planar.html .
the movies and matchings show the geometrically intuitive behavior of the geodesic deformations .
we see that the intermediate structures resemble the geodesic endpoint trees in a reasonable manner , and show the ability of the geodesics to handle internal topological differences .
these are among the wanted properties from the model listed in the beginning of section  [ geometrysection ] .    moreover , computed mean and centroid trees are shown in fig .
[ dataset_means ] ; these are presented in greater detail in  @xcite . the qed average trees clearly represent the main common properties of the dataset trees .      as proof - of - concept experiments on real data
we compute means for sets of pulmonary airway trees from the exact09 airway segmentation competition  @xcite .
the airway trees were first segmented from low dose screening computed tomography ( ct ) scans of the chest using a voxel classification based airway tree segmentation algorithm  @xcite .
the centerlines were extracted from the segmented airway trees using a modified fast marching algorithm based on  @xcite .
the method gives a tree structure directly through connectivity of parent and children branches .
for simplicity , we only consider the upper airway tree down to the lobe branches .
means are computed using both the qed metric ( details found in @xcite ) and using the ted method proposed by trinh and kimia  @xcite .
the dataset is shown in fig .
[ airway_dataset ] , and the results are seen in fig .
[ airway_means ] .
we clearly see how the choice of ted geodesic makes the ted mean vulnerable to noise in the form of missing branches among the dataset trees , giving a mean shape whose structure is too simple .
the qed mean , on the other hand , represents the data well .
airway trees from the exact09 test set .
@xcite ]    th data tree misses these . ]
starting from a purely geometric point of view , we define a shape space for tree - like shapes .
this intuitive geometric framework allows us to simultaneously take both global tree - topological structure and local edgewise geometry into account .
we study two metrics on this shape space , ted and qed , which both give the shape space a geodesic structure ( theorems  [ orderedthm ] and  [ unorderedthm ] ) .
the framework is developed for tree - shapes , but carries over to other geometric trees with vector attributes .
qed is the geometrically most natural metric , and turns out to have properties which are essential for statistical shape analysis . through a geometric analysis of the tree - shape framework
, we show that the qed metric gives local uniqueness of geodesics and local existence and uniqueness for three versions of average shape , namely the mean , the circumcentre and the centroid ( theorem  [ all_averages ] ) .
our analysis gives new insight into the metric space defined by ted , and explains why the problem of finding ted - averages is ill - posed .
both metrics are generally np complete to compute for @xmath8 trees .
we explain how semi - labeling schemes can be used to handle complexity problems , and illustrate this by computing qed means for sets of trees extracted from pulmonary airway trees as well as synthetic planar data trees .
the qed lacks an obvious decomposition strategy for dynamic programming , and involves an optimization term which makes it more time consuming to compute than the ted metric .
the two metrics have similar matching properties , and thus , for applications which do not require a unique geodesic ( e.g. , clustering ) the ted metric is just as suitable as the qed metric .
however , for statistical computations , the qed metric is the only suitable metric .
this is emphasized by our experiments , where computed qed and ted means illustrate that the ted means are missing important structure .
future research will be centered around two points : development of nonlinear statistical methods for the singular tree - shape spaces , and finding more efficient approximations and heuristics for the qed metric using both the tree geometry and the tree - space geometry .
the latter will pave the road for computing averages and modes of variation for large , real @xmath8 data trees .
this is by no means trivial , due to the non - smooth structure of the tree - shape space and the complexity of computing exact distances and geodesics .
the purpose of this appendix is to explain the connection between genericity , defined as a topological property , and probability . in particular , we explain why a generic property can be assumed to hold with probability one , or almost everywhere , with respect to natural probability measures . the main point of the appendix is the contents of theorem  [ mainthm ] .    a property in a topological space @xmath9
is said to be _ generic _ if it holds on a dense , open subset of @xmath9 .
a collection @xmath328 of subsets of some set @xmath9 is a _ @xmath329-algebra _ if @xmath23 has the following properties :    * @xmath330 . * if @xmath331 , then its complement is also an element : @xmath332 . * if @xmath333 for a family @xmath334 , then the union is also an element : @xmath335 .
a _ measure _ on a @xmath329-algebra @xmath23 is a function @xmath336 satisfying the @xmath329-additivity property : if @xmath337 is a countable family of pairwise disjoint subsets in @xmath23 , then @xmath338 .
a property is said to hold _ almost everywhere _ with respect to a probability measure @xmath339 on a space @xmath9 if it holds on a subset @xmath340 such that @xmath341 .
this corresponds to holding with probability one , or _
almost surely_.    assume given a metric space @xmath190 , and @xmath329-algebra @xmath23 which contains the topology induced by @xmath4 , and measure @xmath339 on the sigma - algebra @xmath23 .
assume also given an equivalence class @xmath83 on @xmath9 , and denote by @xmath67 the quotient of @xmath9 with respect to the equivalence .
denote by @xmath342 the projection onto the quotient .
the set @xmath343 is a @xmath329-algebra on @xmath38 .    *
@xmath344 so @xmath345 . *
if @xmath346 then @xmath347 so @xmath348 , so @xmath349 . * if @xmath350 for @xmath334 then @xmath351 for all @xmath117 , so @xmath352 so @xmath353 .
the function @xmath354 given by @xmath355 is a measure on @xmath356 .    if @xmath357 is a countable family of pairwise disjoint subsets in @xmath356 , then @xmath358 is a countable family of pairwise disjoint subsets in @xmath23 , and @xmath359 .
there are lebesgue induced measures @xmath360 and @xmath361 on the tree - spaces @xmath38 and @xmath96 , coming from the lebesgue measure @xmath362 on @xmath9 . for these measures , subsets of positive codimension have measure zero . in particular ,
generic properties hold almost everywhere with respect to the lebesgue induced measure .
@xmath363    recall that we also work on a restricted subspace @xmath10 which consists of trees of certain fixed topologies that are collapsed versions of the maximal tree @xmath15 .
the subspace @xmath11 is a finite union @xmath364 where each @xmath365 is a @xmath4-dimensional linear subspace of @xmath9 corresponding to a certain fixed collapsed version of @xmath15 described by its nonzero edge set @xmath80 .
we assume , moreover , that @xmath366 whenever @xmath367 .
each @xmath365 now has a lebesgue measure @xmath368 of its own , and we obtain a lebesgue induced measure @xmath369 on @xmath11 defined as @xmath370 the measure @xmath369 gives rise to lebesgue induced measures on @xmath88 and @xmath192 as explained above .
there are lebesgue induced measures @xmath371 and @xmath372 on the tree - spaces @xmath88 and @xmath192 , coming from the lebesgue induced measure @xmath369 on @xmath11 . if all @xmath365 have equal dimension , subsets of positive codimension have measure zero . in particular , generic properties
hold almost everywhere with respect to the lebesgue induced measure .
@xmath363    @xcite let @xmath339 and @xmath373 be two measures on a @xmath329-algebra @xmath23 .
the measure @xmath373 is _ absolutely continuous _ with respect to @xmath339 if and only if @xmath374 for each @xmath375 with @xmath376 .    [ mainthm ]
let @xmath373 be a probability measure which is absolutely continuous with respect to the lebesgue induced measure @xmath377 on one of the tree - space @xmath38 or @xmath96 , or of @xmath88 or @xmath192 under the assumption that all @xmath365 have equal dimension .
now any subset of positive codimension has zero measure with respect to @xmath373 .
in particular , generic properties hold almost surely , or with probability @xmath298 , with respect to @xmath373 .
@xmath363    note that the converse is not necessarily true : properties which hold almost surely are not necessarily generic .
in this appendix , we extend the explanation of how the approximate qed distance and geodesic computation specified in section 4.2 in the main paper can be made in practice .
we shall consider computation of distances in the space of ordered trees @xmath38 , as the complete search reduction from ordered trees to the unordered tree - space @xmath96 is not hard to implement
.    recall that the tree - space @xmath38 is constructed from the euclidean space @xmath378 consisting of all trees spanned by a certain maximal combinatorial tree @xmath17 .
the construction is made by identifying different representations of the same tree , with the help of an equivalence relation @xmath83 .
denote by @xmath62 the equivalence class of a point @xmath61 . as discussed in the article
, there is a standard way of defining a distance function on @xmath67 , given by the quotient pseudometric @xmath379 which is shown to be an actual metric .
the quotient space construction is extremely useful for understanding the geometry of tree - space and proving statistical properties of tree - space based on geometry .
however , it is less intuitive how one should proceed in order to actually compute distances in tree - space . in this section
, we shall explain how the tree - space gluings are related to the trees themselves .
recall that two points in @xmath9 are equivalent under @xmath83 and glued together in the formation of @xmath38 if they represent _ the same _ ordered tree - shape .
how can we determine whether two points in tree - space represent the same ordered tree - shape ?
this reduces to a tree isomorphism problem .
more precisely :    * assume given two points @xmath381 .
* these points correspond to two combinatorial trees @xmath382 , equal to or derived from @xmath15 , where some of the edges in @xmath383 may be endowed with zero attributes in @xmath307 .
* create two new combinatorial trees @xmath384 by deleting the edges in @xmath385 and @xmath386 with zero attributes in @xmath5 and @xmath6 , and using the induced orders on siblings from @xmath385 , @xmath386 to induce total orders on siblings in @xmath387 , @xmath388 . *
the question of whether @xmath5 and @xmath6 end up in the same identified subspace is now equivalent to the question of whether @xmath387 and @xmath388 are isomorphic as ordered , combinatorial trees .
the question of whether @xmath5 and @xmath6 represent the same tree - shape , is equivalent to the question of whether a ) @xmath387 and @xmath388 are topologically isomorphic , and b ) if yes , whether their ordered sets of attributes are identical . *
the observations above give us a way to judge whether two points in @xmath9 are equivalent under the equivalence relation @xmath83 on @xmath9 ; equivalently , whether they are identified in @xmath38 .
this realization can be used to reformulate algorithm 1 from the main paper in terms of the trees rather than in terms of the tree - space . * a geodesic in @xmath38
is composed of a set of linear stretches in @xmath9 between equivalence classes that belong to lower - dimensional identified subspaces .
each such stretch can change one endpoint tree to the other endpoint tree by i ) gradually shrinking and removing edges , ii ) adding and gradually extending edges , or iii ) gradually changing edges which are  present  in both trees .
all these changes are made simultaneously at constant speed throughout the linear stretch .
* given two points @xmath389 and @xmath390 in @xmath38 , how can we find the shortest path joining them which consists of two euclidean stretches ?
the length of the shortest such path is @xmath391 .
we shall look at this problem in section  [ twostretches ] below .
* let @xmath389 , @xmath390 be tree - shapes in @xmath38 .
let @xmath69 be some tree - shape whose topological structure can be obtained as a collapsed version of both @xmath389 and @xmath390 .
* the topology of the tree @xmath69 is obtained from @xmath389 ( and similarly from @xmath390 ) by collapsing two types of edges : * * internal edges ( that is , there is some edge in the tree which is further from the root in @xmath389 ( or @xmath390 ) , which is not being collapsed ) , or * * external edges ( that is , all the edges in @xmath389 ( or @xmath390 ) which are farther from the root are also collapsed ) . *
denote the sets of such edges as @xmath393 , @xmath394 , @xmath395 , @xmath396 , respectively .
* we are looking for a point @xmath397 which contains some such @xmath69 as a subtree , such that the shortest two - stretch path from @xmath389 to @xmath390 passes through @xmath398 , and consists of the following types of deformations : * * deformation of all edges that collapse to an edge in @xmath69 ; throughout the whole path . * * gradually deforming all external collapsing edges in @xmath389 so that when we reach @xmath6 , their attributes have become zero ; throughout the whole path . * * gradually growing all external collapsing edges in @xmath390 from zero attributes when the deformation starts in @xmath5 ; throughout the whole path * * gradually deforming all internal collapsing edges in @xmath389 so that when we reach @xmath398 , their attributes are zero ; throughout the first stretch . * * from @xmath398 , gradually grow all internal collapsing edges in @xmath390 ; throughout the second stretch . * * thus , @xmath398 contains the edges from @xmath399 as well as the edges from @xmath394 and @xmath396 .
+ now the distance from @xmath389 to @xmath390 via @xmath398 is : @xmath400 where @xmath401 in case @xmath44 is not an edge in @xmath146 , @xmath402 .
* this is illustrated in figure  [ algorithm ] .
* now we can define @xmath392 : @xmath403 where @xmath398 loops through the set of all trees generated from some tree @xmath69 which is a collapsed version of both @xmath389 and @xmath390 .
the simplest possible path between two tree - shapes does not visit any identified subspaces , and has length @xmath404 .
we have not in an obvious way taken into account that this might in fact be the shortest path . in order to see that this is part of the computation ,
let us start out as above :    * let @xmath389 , @xmath390 be tree - shapes in @xmath38 .
let @xmath69 be some tree - shape whose topological structure can be obtained as a collapsed version of both @xmath389 and @xmath390 .
* the topology of the tree @xmath69 is obtained from @xmath389 ( and similarly from @xmath390 ) by collapsing two types of edges : * * internal edges ( that is , there is some edge in the tree which is further from the root in @xmath389 ( or @xmath390 ) , which is not being collapsed ) , or * * external edges ( that is , all the edges in @xmath389 ( or @xmath390 ) which are farther from the root are also collapsed ) . *
assume that it is possible to find some tree @xmath69 which is obtained by only collapsing external edges .
* the shortest path passing through the corresponding @xmath398 will be a single euclidean stretch , which can be obtained as described above . *
hence , the option that @xmath404 might give the optimal path is part of the computation of @xmath392 .
there is a chance that the intermediate trees appearing in this algorithm are  too large  for @xmath38 ( for example as in fig .
[ algorithm ] .
we have chosen to disregard this , and cut the intermediate trees off in iterative algorithms if they are too large .
this can also be controlled by cutting @xmath398 off by default .      * in order to compute @xmath391 , we need to search through all different collapsed versions @xmath69 of @xmath389 and @xmath390 . *
in order to reduce computation time , we approximate this by setting a bound @xmath267 on the degree of vertices of the collapsed versions . * for @xmath405 , the number of such subtrees is @xmath406 , where @xmath27 is the number of edges in the tree . for @xmath407 ,
the number of such subtrees is @xmath408 . in our experiments we use @xmath405 .
note that if we can answer the question in vii ) in the beginning of section  [ reformulation ] , then we can compute @xmath409 as well : @xmath410 where @xmath398 goes through a family of trees derived from all possible collapsed trees @xmath69 obtained from @xmath389 .
t.  schlathlter , c.  lorenz , i.  c. carlsen , s.  renisch , and t.  deschamps . simultaneous segmentation and tree reconstruction of the airways for virtual bronchoscopy . in _
_ , volume 4684 , pages 103113 , 2002 .