User:BIOalgorithm/sandbox

In graph theory, an interval graph is the intersection graph of a multiset of intervals on the real line. It has one vertex for each interval in the set, and an edge between every pair of vertices corresponding to intervals that overlap.

Definition
Let {I1, I2, ..., In} ⊂ P(R) be a set of intervals.

The corresponding interval graph is G = (V, E), where
 * V = {I1, I2, ..., In}, and
 * {Iα, Iβ} ∈ E if and only if Iα ∩ Iβ ≠ ∅.

From this construction one can verify a common property held by all interval graphs. That is, graph G is an interval graph if and only if the maximal cliques of G can be ordered M1, M2, ..., Mk such that for any v ∈ Mi ∩ Mk, where i &lt; k, it is also the case that v ∈ Mj for any Mj, i ≤ j ≤ k, i.e., there exists a linear order of its maximal cliques such that for each vertex v, all maximal cliques containing v are consecutive.

Efficient recognition algorithms
Several algorithms have been designed to recognize interval graphs in O(|V|+|E|) (linear) time. The original linear time recognition algorithm of is based on their complex PQ tree data structure, but  showed how to solve the problem more simply using lexicographic breadth-first search, based on the fact that a graph is an interval graph if and only if it is chordal and its complement is a comparability graph.

All of the algorithms above rely on seeking an ordering of the maximal cliques of G that is consecutive with respect to vertex inclusion, and the precomputation of all maximal cliques is required. A simpler off-line recognition algorithm was provided by which directly places the intervals without precomputing maximal cliques.

Hsu's Algorithm
The algorithm consists of four main steps: 1 function CLO(G(V, E)): 2 ( ω-1(1), ω-1(2),..., ω-1(n) ) := sort V by their degree in descending order; 3 create a list L of sets with ( ω-1(1), ω-1(2),..., ω-1(n) ) as the only set in it; 4 /* each set in L is kept as a doubly linked list */ 5 for i := 1 to n do 6   begin 7       v := the first element of the first set in L; 8       remove v from L; 9       π(i) := v; 10      split each Lj ∈ L into { N(v) ∩ Lj || Lj \ N(v) }; 11      /* the ω order should remain inside each {N(v) ∩ Lj} and {Lj \ N(v)} */ 12      remove empty sets; 13  end 14 return ( π(1), π(2),..., π(n) );
 * Compute a cardinality lexicographic ordering (CLO) for G. If G is not chordal, stop.


 * Construct subgraph G".
 * In the subgraph, each pair of vertices connected with an edge are strictly adjacent, i.e., the two edges are adjacent but each has a neighbor not adjacent to the other vertice.


 * V" := V


 * E" := { (u, v) | u, v ∈ D, π-1(u) < π-1(v), f(u) ∉ N(v)}


 * D := V - S; S is the set of simplicial vertices in G.


 * f(u) := u's neighbor vertex with the smallest π-index.

1 function G construction((π(1), π(2),..., π(n)), (N(1), N(2),..., N(n))): // N(i) is the neighbor of π(i). 2 keep two arrays with n elements: initialize all n elements of count[n] to FALSE; initialize all n elements of largestN[n] to 0; 3 for i := 1 to n do 4   begin 5       for j := 1 to sizeof N(i) do: 6          begin 7              largestN[N(i)[j]] := i;  8           end 9       for j := 1 to sizeof N(i) do: 10         begin 11             if count[N(i)[j]] equals FALSE do: 12                   count[N(i)[j]] := TRUE; 13                   /* the vertices turned to TRUE in this iteration make up U(π(i)) = {u | f(u) = π(i)} */ 14                   for k := [N(i)[j]] + 1 to n do: 15                      begin 16                          if largestN[k] != i do: 17                              E" += (N(i)[j], k);  18                       end  19               endif  20          end   21    end  22 return E";


 * Compose an S-decomposition tree of G based on the connected components of G".
 * First, we need to obtain the containment relationship of the intervals. The Hasse diagram is built at the same time. In the Hasse diagram, vertices strictly adjacent to each other are grouped and treated as one vertex. This can be done by inserting additional steps into last procedure.
 * (Two lenth-n arrays are added, one integer NewVertex[n] is initialized to NewVertex [ i ] = i; another boolean connected [n] is initialized to FALSE. A counter is kept to record the largest vertex index till now.)

17 E" += (N(i)[j], k);

1  if (connected[N(i)[j]] == TRUE) do 2      connected[k] = TRUE; 3      NewVertex[k] = NewVertex[N(i)[j]]; 4  endif 5  else if (connected[k] == TRUE) do 6      connected[N(i)[j]] = TRUE; 7      NewVertex[N(i)[j]] = NewVertex[k]; 8  end elseif 9  else do 10     connected[N(i)[j]] = connected[k] = TRUE; 11     NewVertex[N(i)[j]] = NewVertex[k] = counter++; 12 end else


 * Then we can get the S-decomposition tree. One thing to note is that we need to avoid cycle in G" while building it. To do this, for each group of connected edges(and vertices), we assign one represented vertex to all edges(and all vertices) in the group, then the check before each edge addition becomes easy. For example, before we add the new edge E(u, v), we only need to compare the represented vertex of u and that of v, no cycle will occur if the two are different.


 * Test each S-prime component to see if it is an interval graph.
 * This can be done by truly building the corresponding interval graph; first adding the non-simplicial vertices, then adding the simplicial vertices through a linear scan. The second part is intuitive; the first part needs more detailed discussion.

Lemma Let uk be the next interval to be placed, which is not a neighbor of previously chosen intervals. Let uj be the parent of uk and ui be the parent of uj in the BFS-tree. It can be determined uniquely which endpoints of uj or ui is contained in uk.

There are three cases, place each edge according to its category.
 * Case 1: (f(ui), uj) ∉ E. If ui ,uk are on the different side of uj, uk would contain uj.
 * Case 2: (f(uk), uj ) ∉ E. Again, if ui, uk are on the different side of uj, uk would contain uj.
 * Case 3: (f(uj), uk) ∉ E and (f(uj), ui) ∉ E. If ui ,uk are on the different sides of uj, uk cannot be adjacent to ui.
 * (f(u) := u's neighbor vertex with the smallest π-index.)

Related families of graphs
Interval graphs are chordal graphs and hence perfect graphs. Their complements belong to the class of comparability graphs, and the comparability relations are precisely the interval orders.

The interval graphs that have an interval representation in which every two intervals are either disjoint or nested are the trivially perfect graphs.

Proper interval graphs are interval graphs that have an interval representation in which no interval properly contains any other interval; unit interval graphs are the interval graphs that have an interval representation in which each interval has unit length. Every proper interval graph is a claw-free graph. However, the converse is not true. Every claw-free graph is not necessarily a proper interval graph. If the collection of segments in question is a set, i.e.,  no repetitions of segments is allowed, then the graph is unit interval graph if and only if it is proper interval graph.

The intersection graphs of arcs of a circle form circular-arc graphs, a class of graphs that contains the interval graphs. The trapezoid graphs, intersections of trapezoids whose parallel sides all lie on the same two parallel lines, are also a generalization of the interval graphs.

The pathwidth of an interval graph is one less than the size of its maximum clique (or equivalently, one less than its chromatic number), and the pathwidth of any graph G is the same as the smallest pathwidth of an interval graph that contains G as a subgraph.

The connected triangle-free interval graphs are exactly the caterpillar trees.

Applications
The mathematical theory of interval graphs was developed with a view towards applications by researchers at the RAND Corporation's mathematics department, which included young researchers—such as Peter C. Fishburn and students like Alan C. Tucker and Joel E. Cohen—besides leaders—such as Delbert Fulkerson and (recurring visitor) Victor Klee. Cohen applied interval graphs to mathematical models of population biology, specifically food webs.

Other applications include genetics, bioinformatics, and computer science. Finding a set of intervals that represent an interval graph can also be used as a way of assembling contiguous subsequences in DNA mapping. Interval graphs are used to represent resource allocation problems in operations research and scheduling theory. Each interval represents a request for a resource for a specific period of time; the maximum weight independent set problem for the graph represents the problem of finding the best subset of requests that can be satisfied without conflicts. Interval graphs also play an important role in temporal reasoning.