コード例 #1
0
def go():
    forbidden = [make_clique(4), make_cycle(4), make_clique(6), make_cycle(8)]
    onlyfiles = [ f for f in listdir(MYPATH) if isfile(join(MYPATH,f)) ]
    for f in onlyfiles:
        print("Working on:")
        print(f)
        g = File(MYPATH,file=f).load(f)
        check_graph(DROPS, g, forbidden)
    return
コード例 #2
0
 def testCheckCondition(self):
     test = check_condition_holds(make_clique(5))
     expect = False
     self.assertEqual(test, expect)
     test = check_condition_holds(make_clique(3))
     expect = False
     self.assertEqual(test, expect)
     test = check_condition_holds(make_cycle(5))
     expect = True
     self.assertEqual(test, expect)
コード例 #3
0
ファイル: free.py プロジェクト: fras2560/research
 def testCreateSubdivision(self):
     # test one zero paths and 1 path$
     g = ISK4Free(make_co_twin_c5())
     result = g.create_subdivions([0,0,0,0,0,0])
     self.assertEqual(self.compare_graphs(result, make_clique(4)), True)
     result = g.create_subdivions([1,0,0,0,0,0])
     expect = make_clique(4)
     expect.remove_edge(2, 3)
     expect.add_node(4)
     expect.add_edge(2,4)
     expect.add_edge(3,4)
     self.assertEqual(self.compare_graphs(result, expect), True)
コード例 #4
0
ファイル: free.py プロジェクト: fras2560/research
 def free(self):
     '''
     a method to determine if the graph is ISK4-free
     Parameters:
         None
     Returns:
         sub: list of vertices that form a ISK4
                 is None if does not contain (list)
     '''
     # check if omega is greater than four
     sub = None
     if nx.graph_clique_number(self.g) > 3:
         sub = induced_subgraph(self.g, make_clique(4))
     else:
         # loop through all possible subdivisions between 4 and n
         n = len(self.g.nodes())
         i = 0
         while i < n - 3 and sub is None:
             for ball in unlabeled_balls_in_unlabeled_boxe(i,
                                                           [i]*6):
                 graph = self.create_subdivions(ball)
                 sub = induced_subgraph(self.g, graph)
                 if sub is not None:
                     break
             i += 1
     return sub
コード例 #5
0
 def testFindEliminatinSet(self):
     expect = find_eliminating_set(make_claw())
     self.assertEqual(expect, [])
     expect = find_eliminating_set(make_diamond())
     self.assertEqual(expect, [0])
     print()
     expect = find_eliminating_set(make_clique(4))
     self.assertEqual(expect, [])
コード例 #6
0
ファイル: free.py プロジェクト: fras2560/research
 def testFree(self):
     # simple case
     g = ISK4Free(make_clique(4))
     result = g.free()
     self.assertEqual(self.compare_graphs(result, make_clique(4)), True)
     # another simple case
     g = ISK4Free(make_co_twin_c5())
     result = g.free()
     expect = make_co_twin_c5()
     self.assertEqual(self.compare_graphs(result, expect), True)
     # difficult graph
     graph = make_cycle(5)
     graph.add_node(5)
     graph.add_edge(0, 5)
     graph.add_edge(1, 5)
     graph.add_edge(3, 5)
     g = ISK4Free(graph)
     result = g.free()
     self.assertEqual(self.compare_graphs(result, graph), True)
     # one with no ISK4
     graph = make_cycle(6)
     g = ISK4Free(graph)
     result = g.free()
     self.assertEqual(result, None)
コード例 #7
0
ファイル: clique_cutset.py プロジェクト: fras2560/research
 def testCliqueCutset(self):
     # no cutset
     result = clique_cutset(make_cycle(5))
     self.assertEqual(result, None)
     # cutset is subclique of the maximal clique
     result = clique_cutset(make_diamond())
     self.assertEqual(result, (0, 1))
     # just a normal cutset
     result = clique_cutset(make_kite())
     self.assertEqual(result, (2,))
     # whole graph is a clique
     result = clique_cutset(make_clique(4))
     self.assertEqual(result, (0, 1, 2, 3))
     # a random graph
     result = clique_cutset(make_bridge())
     self.assertEqual(result, (0, 1))
コード例 #8
0
ファイル: find_4Chromatic.py プロジェクト: fras2560/research
from graph.helper import make_claw, make_cycle, make_clique
from graph.helper import make_diamond, forbidden_line_subgraphs
from os import getcwd
from os.path import join
from generator import Generator2 
from file import File
import logging
from pprint import PrettyPrinter
from graph.colorable import coloring
from networkx import complement
pp = PrettyPrinter(indent = 4)
XCHROMATIC = 5

# create forbidden graph
k4 = make_clique(XCHROMATIC)
co_k4 = complement(make_clique(4))

# these constants are what should change
FAMILY = "Line(Co-K4)-free"
DIRECTORY = join(getcwd(), 'GraphFamilies', FAMILY)
FORBIDDEN = forbidden_line_subgraphs() + [co_k4, k4]
print(FORBIDDEN)
STARTING = make_cycle(7)
BASE = "C5"
logging.basicConfig(filename=FAMILY + BASE + ".log", level=logging.INFO,
                            format='%(asctime)s %(message)s')
LOGGER = logging.getLogger(__name__)
# processing work 
generator = Generator2(STARTING, 10, FORBIDDEN)
index = 0
コード例 #9
0
 def testNonAdjacent(self):
     self.assertEqual(non_adjacent([1,2], make_clique(4)), False)
     self.assertEqual(non_adjacent([1,2], make_cycle(4)), False)
     self.assertEqual(non_adjacent([1,3], make_cycle(4)), True)
コード例 #10
0
from os import getcwd
from os.path import join
import os
from graph.helper import make_clique, make_cycle
from utility.file import File
from utility.generator import Generator
import logging

REQUIREMENT  = 3
logging.basicConfig(filename="hoang_conjecture.log", level=logging.INFO,
                            format='%(asctime)s %(message)s')
LOGGER = logging.getLogger(__name__)

REQUIREMENT = 4
DROPS  = 10
FORBIDDEN = [make_clique(4), make_cycle(4), make_clique(6), make_cycle(8)]
MYPATH = join(getcwd(), "special_graphs", "Non_adjacent")
GRAPH = make_cycle(5)

def go():
    for g in Generator(GRAPH, DROPS, FORBIDDEN, logger=LOGGER).iterate():
        if not check_condition_holds(g):
            f = File(MYPATH, G=g, logger=LOGGER, base="")
            fp = f.save()
            LOGGER.info("Found the special graph")
            print("Found the special graph")

def check_condition_holds(g):
    '''
    a function that checks if there are two non-adjacent vertices with d(v)<=3
    Parameters:
コード例 #11
0
 def testSpecialGraph(self):
     self.assertEqual(special_graph(make_cycle(4)), False)
     self.assertEqual(special_graph(make_clique(5)), True)  
コード例 #12
0
ファイル: conjecture.py プロジェクト: fras2560/research
from utility.file import File
from utility.generator import Generator
from graph.helper import make_cycle, make_clique, make_co_twin_c5
import logging
from os.path import join
from os import getcwd

# constants
REQUIREMENT = 4

logging.basicConfig(filename="d3_set_conjecture.log", level=logging.INFO,
                            format='%(asctime)s %(message)s')
LOGGER = logging.getLogger(__name__)

DROPS  = 10
FORBIDDEN = [make_clique(4), make_co_twin_c5(),make_cycle(4), make_cycle(6), make_cycle(8)]
MYPATH = join(getcwd(), "counter_example", "d3" )
GRAPH = make_cycle(5)

def go():
    print("Two v d(v1) <= d(v2) < 4")
    count = 0
    for g in Generator(GRAPH, DROPS, FORBIDDEN, logger=LOGGER).iterate():
        count += 1
        if not conjecture_holds(g):
            f = File(MYPATH, G=g, logger=LOGGER, base="")
            fp = f.save()
            LOGGER.info("Found the special graph")
            print("Found the special graph")
        if count % 1000 == 0:
            print("Checked {} graphs".format(count))
コード例 #13
0
ファイル: find_critical.py プロジェクト: fras2560/research
Created on Sep 16, 2015

@author: Dallas
'''
import sys
sys.path.append("..") # Adds higher directory to python modules path.
from graph.helper import make_cycle, make_clique, make_clique, make_wheel
from utility.file import File
from graph import DalGraph
import os
from utility.generator import Generator
from EvenHoleFree.helper import critical_cycle 
import logging
from pprint import PrettyPrinter
pp = PrettyPrinter(indent = 4)
FORBIDDEN =  [make_clique(4),
              make_cycle(4),
              make_cycle(6),
              make_cycle(8),
              make_cycle(5),
              make_wheel(6)
              ]
BASE = "C&"
DIRECTORY=os.path.join(os.getcwd(), "Critical-graphs", BASE)
STARTING = make_cycle(7)
logging.basicConfig(filename=BASE+"finding_critical.log", level=logging.INFO,
                            format='%(asctime)s %(message)s')
LOGGER = logging.getLogger(__name__)
DROPS = 10

def go():
コード例 #14
0
ファイル: create_graphs.py プロジェクト: fras2560/research
from graph.helper import join as graphjoin
from os import getcwd
from os.path import join
from utility.generator import Generator2
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,