# Ptolemaic graph

In graph theory, a Ptolemaic graph is an undirected graph whose shortest path distances obey Ptolemy's inequality, which in turn was named after the Greek astronomer and mathematician Ptolemy. The Ptolemaic graphs are exactly the graphs that are both chordal and distance-hereditary; they include the block graphs and are a subclass of the perfect graphs.

## Characterization

A graph is Ptolemaic if and only if it obeys any of the following equivalent conditions:
* The shortest path distances obey Ptolemy's inequality: for every four vertices u, v, w, and x, the inequality d(u,v)d(w,x) + d(u,x)d(v,w) ≥ d(u,w)d(v,x) holds. For instance, the gem graph (3-fan) in the illustration is not Ptolemaic, because in this graph d(u,w)d(v,x) = 4, greater than d(u,v)d(w,x) + d(u,x)d(v,w) = 3.
* For every two overlapping maximal cliques, the intersection of the two cliques is a separator that splits the differences of the two cliques. In the illustration of the gem graph, this is not true: cliques uvy and wxy are not separated by their intersection, y, because there is an edge vw that connects the cliques but avoids the intersection.
* Every k-vertex cycle has at least 3(k − 3)/2 diagonals.
* The graph is both chordal (every cycle of length greater than three has a diagonal) and distance-hereditary (every connected induced subgraph has the same distances as the whole graph). The gem shown is chordal but not distance-hereditary: in the subgraph induced by uvwx, the distance from u to x is 3, greater than the distance between the same vertices in the whole graph. Because both chordal and distance-hereditary graphs are perfect graphs, so are the Ptolemaic graphs.
* The graph is chordal and does not contain an induced gem, a graph formed by adding two non-crossing diagonals to a pentagon.
* The graph is distance-hereditary and does not contain an induced 4-cycle.
* The graph can be constructed from a single vertex by a sequence of operations that add a new degree-one (pendant) vertex, or duplicate (twin) an existing vertex, with the exception that a twin operation in which the new duplicate vertex is not adjacent to its twin (false twins) can only be applied when the neighbors of the twins form a clique. These three operations without the exception form all distance-hereditary graph. To form all Ptolemaic graphs, it is not enough to use pendant vertices and true twins; the exceptional case of false twins is sometimes also required.
* The Hasse diagram of the subset relation on nonempty intersections of maximal cliques forms an oriented tree.
* The convex subsets of vertices (subsets that contain every shortest path between two vertices in the subset) form a convex geometry. That is, every convex set can be reached from the whole vertex set by repeatedly removing an extreme vertex, one that does not belong to any shortest path between the remaining vertices. In the gem, the convex set uxy cannot be reached in this way, because neither v nor w is extreme.

## Computational complexity

Based on the characterization by oriented trees, Ptolemaic graphs can be recognized in linear time.

## Enumeration

The generating function for Ptolemaic graphs can be described symbolically, allowing the fast calculation of the numbers of these graphs. Based on this method, the number of Ptolemaic graphs with n labeled vertices, for $n=1,2,3,\dots$, has been found to be
    1, 1, 4, 35, 481, 9042, 216077, 6271057, 214248958, 8424002973, 374708368981, 18604033129948, 1019915376831963, ... (sequence A287886 in the OEIS)