IMT.py
def ComputeLRecursive(G,i,n,V_add):
    """Explore all the possible subgraphs of G and update the dictionnary L 
    to keep track of the maximum.
    
    INPUTS:
        G - the graph of the connected component of the original graph 
        (without the rejected vertices) containing the vertices of V_add
        i - the vertex of G, the procedure has to branch on.
        n - The number of vertices of the graph it explores
        V_add - A set of vertices that are already included in the solution
        
    OUTPUT:
        Branchs with including/excluding a vertex i of the solution. 
        When at the end of the research tree, updates a global dictonnary 
        L created by ComputeL(G)
    """
    global L
    (l,connexity_lack)=subgraphStat(G,V_add)
    acyclic=(l!=-1)
    m=len(V_add)
    promising=sum([L[m]<l*(connexity_lack==0)]+[L[m+j]<l+j-connexity_lack for j in range(1,G.num_verts()-m)])>0
    if i==n and acyclic and connexity_lack==0:
        #All vertices are either included or excluded
        L[m]=max(L[m],l)  
    elif acyclic and promising and i<n:
        #The branch is valid and promising
        if i in G.vertices():
            #The vertex is in the connected component G
            V_add.add(i)
            ComputeLRecursive(G,i+1,n,V_add)
            V_add.remove(i)
            neighbors_of_i=G.neighbors(i)
            G.delete_vertex(i)
            connected_component=G
            connectable=True
            if len(V_add)>0:
                for v in V_add: break
                C=G.connected_component_containing_vertex(v)
                connectable=V_add.issubset(C)
                if len(C)<G.num_verts():
                    connected_component=G.subgraph(vertices=C,algorithm="add")
            if connectable:
                #rejecting i does not separate V_add
                ComputeLRecursive(connected_component,i+1,n,V_add)
            G.add_vertex(i)
            for j in neighbors_of_i:
                G.add_edge(i,j)
        else:
            #The vertex is not in the connected component G
            ComputeLRecursive(G,i+1,n,V_add)
Explore all the possible subgraphs of G and update the dictionnary L 
    to keep track of the maximum.
    
    INPUTS:
        G - the graph of the connected component of the original graph 
        (without the rejected vertices) containing the vertices of V_add
        i - the vertex of G, the procedure has to branch on.
        n - The number of vertices of the graph it explores
        V_add - A set of vertices that are already included in the solution
        
    OUTPUT:
        Branchs with including/excluding a vertex i of the solution. 
        When at the end of the research tree, updates a global dictonnary 
        L created by ComputeL(G)
    
Explore all the possible subgraphs of G and update the dictionnary L
to keep track of the maximum.

the graph of the connected component of the original graph
(without the rejected vertices) containing the vertices of V_add
i - the vertex of G, the procedure has to branch on.
n - The number of vertices of the graph it explores
V_add - A set of vertices that are already included in the solution

Branchs with including/excluding a vertex i of the solution.
When at the end of the research tree, updates a global dictonnary
L created by ComputeL(G)
Explore all the possible subgraphs of G and update the dictionnary L to keep track of the maximum . the graph of the connected component of the original graph ( without the rejected vertices ) containing the vertices of V_add i - the vertex of G the procedure has to branch on . n - The number of vertices of the graph it explores V_add - A set of vertices that are already included in the solution Branchs with including / excluding a vertex i of the solution . When at the end of the research tree updates a global dictonnary L created by ComputeL ( G )
def ComputeLRecursive(G,i,n,V_add):
    global L
    (l,connexity_lack)=subgraphStat(G,V_add)
    acyclic=(l!=-1)
    m=len(V_add)
    promising=sum([L[m]<l*(connexity_lack==0)]+[L[m+j]<l+j-connexity_lack for j in range(1,G.num_verts()-m)])>0
    if i==n and acyclic and connexity_lack==0:
        L[m]=max(L[m],l)  
    elif acyclic and promising and i<n:
        if i in G.vertices():
            V_add.add(i)
            ComputeLRecursive(G,i+1,n,V_add)
            V_add.remove(i)
            neighbors_of_i=G.neighbors(i)
            G.delete_vertex(i)
            connected_component=G
            connectable=True
            if len(V_add)>0:
                for v in V_add: break
                C=G.connected_component_containing_vertex(v)
                connectable=V_add.issubset(C)
                if len(C)<G.num_verts():
                    connected_component=G.subgraph(vertices=C,algorithm="add")
            if connectable:
                ComputeLRecursive(connected_component,i+1,n,V_add)
            G.add_vertex(i)
            for j in neighbors_of_i:
                G.add_edge(i,j)
        else:
            ComputeLRecursive(G,i+1,n,V_add)
def ComputeLRecursive ( G , i , n , V_add ) : global L ( l , connexity_lack ) = subgraphStat ( G , V_add ) acyclic = ( l != - 1 ) m = len ( V_add ) promising = sum ( [ L [ m ] < l * ( connexity_lack == 0 ) ] + [ L [ m + j ] < l + j - connexity_lack for j in range ( 1 , G . num_verts ( ) - m ) ] ) > 0 if i == n and acyclic and connexity_lack == 0 : L [ m ] = max ( L [ m ] , l ) elif acyclic and promising and i < n : if i in G . vertices ( ) : V_add . add ( i ) ComputeLRecursive ( G , i + 1 , n , V_add ) V_add . remove ( i ) neighbors_of_i = G . neighbors ( i ) G . delete_vertex ( i ) connected_component = G connectable = True if len ( V_add ) > 0 : for v in V_add : break C = G . connected_component_containing_vertex ( v ) connectable = V_add . issubset ( C ) if len ( C ) < G . num_verts ( ) : connected_component = G . subgraph ( vertices = C , algorithm = "add" ) if connectable : ComputeLRecursive ( connected_component , i + 1 , n , V_add ) G . add_vertex ( i ) for j in neighbors_of_i : G . add_edge ( i , j ) else : ComputeLRecursive ( G , i + 1 , n , V_add )
Explore all the possible subgraphs of G and update the dictionnary L
to keep track of the maximum.
Explore all the possible subgraphs of G and update the dictionnary L to keep track of the maximum .
"""Explore all the possible subgraphs of G and update the dictionnary L 
    to keep track of the maximum.
    
    INPUTS:
        G - the graph of the connected component of the original graph 
        (without the rejected vertices) containing the vertices of V_add
        i - the vertex of G, the procedure has to branch on.
        n - The number of vertices of the graph it explores
        V_add - A set of vertices that are already included in the solution
        
    OUTPUT:
        Branchs with including/excluding a vertex i of the solution. 
        When at the end of the research tree, updates a global dictonnary 
        L created by ComputeL(G)
    """ #All vertices are either included or excluded #The branch is valid and promising #The vertex is in the connected component G #rejecting i does not separate V_add #The vertex is not in the connected component G
G
i
n
V_add