Example #1
0
 def testForbidden(self):
     claw = make_claw()
     c4 = make_cycle(4)
     cok4 = make_cok4()
     g = make_cycle(5)
     not_allowed = [claw, c4, cok4]
     gen = Generator2(g, 1, forbidden=not_allowed)
     for graph in gen.iterate():
         for h in not_allowed:
             if induced_subgraph(graph, h) is not None:
                 print(graph.edges())
                 print(h.edges())
                 self.assertEqual(True, False ,"Failed to forbid a graph")
Example #2
0
from copy import deepcopy
from utility.file import File
from os import getcwd
from os.path import join
from graph.colorable import chromatic_number
from networkx.algorithms.clique import graph_clique_number
import logging

MAX_X_CARDINALITY = 2
BASE_CYCLE_SIZE = 7
BASE_GRAPH = make_cycle(BASE_CYCLE_SIZE)
LOG_FILE_NAME = "C7_Many_X_Enumerate.log"
GRAPH_FAMILY = "(C4-C5-4k1)-free-C5-Many-Zs"
DIRECTORY = join(getcwd(), "GraphFamilies", GRAPH_FAMILY)
MY_LOGGER = logging.getLogger(__name__)
FORBIDDEN_SUBGRAPHS = {make_cok4(), make_cycle(4), make_cycle(5)}

def GIsHFree(G, H):
    
    result = True
    
    for thisForbiddenInducedSubgraph in H:
        if induced_subgraph(G, thisForbiddenInducedSubgraph):
            result = False
            break
    return result

def WriteToLogFile(strMsg):
    
    logFileHandle = open(LOG_FILE_NAME, "a+", encoding = "utf-8")
    thisLine = logFileHandle.readline().strip()
Example #3
0
import sys
sys.path.append("..") # Adds higher directory to python modules path.
from graph.helper import make_cycle, make_cok4
from os import getcwd
from os.path import join
from utility.file import File
from itertools import combinations_with_replacement, permutations
from graph.container import induced_subgraph
import logging

FAMILY = "(C4,C6,4K1)-free"
DIRECTORY = join(getcwd(), 'GraphFamilies', FAMILY)
YIVALUE = 1
ZIVALUE = 2
BASE = make_cycle(7)
FORBIDDEN = [make_cycle(4), make_cycle(6), make_cok4()]
BOTH = 3
logging.basicConfig(filename=FAMILY + "Enumerate.log", level=logging.INFO, format='%(asctime)s %(message)s')
LOGGER = logging.getLogger(__name__)

def add_vertices(G, permutation):
    ypositions = [0, 0, 0, 0, 0, 0, 0]
    zpositions = [0, 0, 0, 0, 0, 0, 0]
    vertex = 7
    for i, value  in enumerate(permutation):
        if value == YIVALUE or value == BOTH:
            #add the new Y vertex and its edges
            G.add_node(vertex)
            G.add_edge(vertex, i)
            G.add_edge(vertex, (i+1) % 7)
            G.add_edge(vertex, (i+4) % 7)
Author:  Tom LaMantia
ID:      110242560
Email:   [email protected]
Version: 2015-08-09
-------------------------------------------------------
"""
import sys
sys.path.append("..") #Adds higher directory modules to python path
from graph.helper import make_cycle, make_cok4
from os import getcwd
from os.path import join
from utility.generator import Generator2
from utility.file import File
import logging

FORBIDDEN_SUBGRAPHS = [make_cycle(4), make_cycle(5), make_cycle(7), make_cok4()]

FAMILY = "C7-free"
DIRECTORY = join(getcwd(), 'GraphFamilies', FAMILY)
BASE_CYCLE = make_cycle(6)
BASE = "C7-free"
logging.basicConfig(filename=BASE+FAMILY+".log", level=logging.INFO, format='%(asctime)s %(message)s')
LOGGER = logging.getLogger(__name__)

generator = Generator2(BASE_CYCLE, 4, FORBIDDEN_SUBGRAPHS)
index = 0

for graph in generator.iterate():
    print("t")
    f = File(DIRECTORY, G=graph, logger=LOGGER, base=BASE)
    fp = f.save()
from graph.container import induced_subgraph
from graph.colorable import chromatic_number
from itertools import product, repeat, combinations
import copy
import logging
from os import getcwd
from os.path import join
from utility.file import File
from networkx.algorithms.clique import graph_clique_number

GRAPH_FAMILY = "(C4-C6-4k1)-free-C5-Z0-Z1"
DIRECTORY = join(getcwd(), 'GraphFamilies', GRAPH_FAMILY)
LOGGER = logging.getLogger(__name__)

MAX_Z_SIZE = 5
FORBIDDEN = {make_cok4(), make_cycle(4), make_cycle(6)}
LOG_FILE_NAME = "C5_Z_CliqueSize_ChromaticNum.log"

"""
-------------------------------------------------------
This function determines if the clique number of some arbitrary
graph G equals the chromatic number
-------------------------------------------------------
Preconditions:
    G: a Networkx graph
Postconditions:
    Returns True if the clique number of G equals the chromatic number
    of G, False otherwise.
-------------------------------------------------------
"""
def ChromaticNumberEqualsCLiqueNumber(G):
Example #6
0
from utility.file import File
import logging
from utility.EmailHelper import send_email

TO_ADDRESS = "*****@*****.**"
CREATE_MESSAGE = "Create Graphs was completed"
# create forbidden graph
c4 = make_cycle(4)
c6 = make_cycle(6)
c8 = make_cycle(8)
c10 = make_cycle(10)
k4 = make_clique(4)

coclaw = make_co_claw()
k2 = make_2K2()
cok4 = make_cok4()
codiamond = make_co_diamond()

# these constants are what should change
FAMILY = "Even-Hole"
DIRECTORY = join(getcwd(), 'GraphFamilies', FAMILY)
FORBIDDEN = [c4, c6, c8, c10, k4]
STARTING = make_co_cycle(5)
BASE = "C5"
logging.basicConfig(
    filename=BASE + FAMILY + ".log",
    level=logging.INFO,
    format='%(asctime)s %(message)s')
LOGGER = logging.getLogger(__name__)
# processing work
generator = Generator2(STARTING, 5, FORBIDDEN)
Example #7
0
from itertools import product
from utility.file import File
from os import getcwd
from os.path import join
from graph.colorable import chromatic_number
from networkx.algorithms.clique import graph_clique_number
import logging

LOG_FILE_NAME = "C5_Many_Z_Enumerate.log"
GRAPH_FAMILY = "(C4-C6-4k1)-free-C5-Many-Zs"
DIRECTORY = join(getcwd(), "GraphFamilies", GRAPH_FAMILY)
MY_LOGGER = logging.getLogger(__name__)

NUMBER_OF_Z_SETS = 5
Z_SETS = []
FORBIDDEN_INDUCED_SUBGRAPHS = {make_cok4(), make_cycle(4), make_cycle(6)}

def WriteToLogFile(strMsg):
    
    logFileHandle = open(LOG_FILE_NAME, "a+", encoding = "utf-8")
    thisLine = logFileHandle.readline().strip()
    while thisLine != "":
        thisLine =  logFileHandle.readline().strip()

    print(strMsg, file = logFileHandle)
    logFileHandle.close()
    
    return

"""
-------------------------------------------------------