def FindStrongStableSetWithY(G):
    result = None
    maximalCliques = findLargestCliques(G)
    V = G.nodes()

    for thisVertex in [i for i in V if i > 13]:
        #Find maximum stable sets which contain each vertex of G
         try:
            verticesToInclude = list()
            verticesToInclude.append(thisVertex)
            thisMaximalStableSet = maximal_independent_set(G, verticesToInclude)
         except NetworkXUnfeasible:
            thisMaximalStableSet = []
         #Now determine if thisMaximumStableSet is strong, that is, meets every maximal clique
         foundStrongStableSet = True
        
         for thisMaximalClique in maximalCliques:
            if set(thisMaximalStableSet).isdisjoint(set(thisMaximalClique)):
                foundStrongStableSet = False
                break
                   
         if foundStrongStableSet == True:
            result = thisMaximalStableSet
            break

    return result
def FindSimpleStableSet(G):
 
    result = None
     
    while result == None:
            result = maximal_independent_set(G)
            if len(result) != 3:
                result = None
    return result
def FindGoodStableSet(G):

    graphToSearch = deepcopy(G)
    for i in range(0, CYCLE_LENGTH):
        graphToSearch.remove_node(i)

    for i in range(0,10):
        try:
            result = maximal_independent_set(graphToSearch)
        except IndexError:
            return None
        if len(result) == 3:
            break
    
    if len(result) != 3:
        result = None

    return result
def FindStrongStableSet(G):
    
    """
    -------------------------------------------------------
    This function finds a strong stable set in a NetworkX graph.
    -------------------------------------------------------
    Preconditions:
        G - a NetworkX graph.
    
    Postconditions: 
        returns: result - a strong stable set in G if one exists,
        and returns [] otherwise. 
    -------------------------------------------------------
    """
    
    result = None
    maximalCliques = FindLargestCliques(G)
    V = G.nodes()

    for thisVertex in V:
        #Find maximum stable sets which contain each vertex of G
         try:
            verticesToInclude = list()
            verticesToInclude.append(thisVertex)
            thisMaximalStableSet = maximal_independent_set(G, verticesToInclude)
         except NetworkXUnfeasible:
            thisMaximalStableSet = []
         #Now determine if thisMaximumStableSet is strong, that is, meets every maximal clique
         foundStrongStableSet = True
        
         for thisMaximalClique in maximalCliques:
            if set(thisMaximalStableSet).isdisjoint(set(thisMaximalClique)):
                foundStrongStableSet = False
                break
                   
         if foundStrongStableSet == True:
            result = thisMaximalStableSet
            break

    return result
    for (u, v, attributes) in G.edges(data=True):
        attributes.clear()


# -------------------- ENTRY POINT -------------------- #

# Building graph and removing attributes
fileName = sys.argv[1]
strategy = sys.argv[2]
G = read_dot(fileName)
G = nx.DiGraph(nx.convert_node_labels_to_integers(G))
remove_attributes(G)

#Slicing string to get rid of file path
i = sys.argv[1].rfind("/") + 1
fileName = sys.argv[1][i:]
fileName = fileName.split(".")[0]

# Directed graph metrics
bc = getBetweness(G, True)
#cc = getClosenessCentrality(G, True)

## Undirected graph metrics
#subgc = getSubgraphCentrality(G, True)
#print(subgc)
domset = getDominatingSet(G)
print(domset)
print(maximal_independent_set(nx.Graph(G)))
placementHeatmap(G, fileName, strategy, bc)
#write_dot(G, fileName + ".dot")