Example #1
0
import graphFunctions
import searchTree
import searchTreeNode as nd
import time
# E-mail stuff
import smtplib

for i in range(6):
    # Name of the file containing edges for the graph
    FILENAME = "sampleGraphs/links2010.edges-" + str(i) + ".anonGraph"
    content = FILENAME + "\n"

    graph = graphFunctions.read_edges_from_file(FILENAME, " ")

    for j in range(graph.number_of_nodes()/8, graph.number_of_nodes()/2):
        for k in range(1, len(graph.edges())/12):
            tree = searchTree.SearchTree()
            print "Working on a graph with", graph.number_of_nodes(), "vertices"
            msg = "Working on a graph with " + str(graph.number_of_nodes()) + " vertices\n"
            tree.set_root(nd.Node(graph.edges(),0))

            print "Looking for at most", k, "edges to delete, so as to"
            print "separate the graph into components of size at most", j, "nodes"
            msg = msg + "Looking for at most " + k + " edges to delete, so as to\n"
            msg = msg + "separate the graph into components of size at most " + j + " nodes\n"
            # Code to track execution time
            print "Starting search..."
            start_time = time.time()

            # Change search method HERE --v
            minEdges = tree.breadth_first_search(15,3)
Example #2
0
import graphFunctions
import searchTree
import searchTreeNode as nd
import time
# E-mail stuff
import smtplib

for i in range(6):
    # Name of the file containing edges for the graph
    FILENAME = "sampleGraphs/links2010.edges-" + str(i) + ".anonGraph"
    content = FILENAME + "\n"

    graph = graphFunctions.read_edges_from_file(FILENAME, " ")

    for j in range(graph.number_of_nodes() / 8, graph.number_of_nodes() / 2):
        for k in range(1, len(graph.edges()) / 12):
            tree = searchTree.SearchTree()
            print "Working on a graph with", graph.number_of_nodes(
            ), "vertices"
            msg = "Working on a graph with " + str(
                graph.number_of_nodes()) + " vertices\n"
            tree.set_root(nd.Node(graph.edges(), 0))

            print "Looking for at most", k, "edges to delete, so as to"
            print "separate the graph into components of size at most", j, "nodes"
            msg = msg + "Looking for at most " + k + " edges to delete, so as to\n"
            msg = msg + "separate the graph into components of size at most " + j + " nodes\n"
            # Code to track execution time
            print "Starting search..."
            start_time = time.time()
    baseFiles.append(line.strip())
    

    
startString = "TreeDecomp"
endString = ".dgf.txt"

for baseFile in baseFiles:
    
    decompName = startString + baseFile + endString

    tree = jd.readDot(decompName)
    root = tree.nodes()[0]
    neighbours = tree.neighbors(root)
    td.make_it_nice(tree, root, neighbours)
    graph = gf.read_edges_from_file(baseFile, " ")

    
    root = tree.nodes()[0]
    tree = td.get_nice_tree_decomp(tree, root)
    orderOfComputation = list(nx.dfs_postorder_nodes(tree,root))
    
    delValuesTable = {}
    for guy in orderOfComputation:
         print str(guy)  +" has kind " + tree.node[guy ]["kind"] + " and bag " + tree.node[guy ]["label"] + " and neighbours " + str(tree.neighbors(guy))

    maxK = len(graph.edges())
    maxH = 6
    hSolved = False
    start1 = time.time()
    for h in range(5, maxH):
baseFiles = []
for line in open(fileOfFiles):
    baseFiles.append(line.strip())

startString = "TreeDecomp"
endString = ".dgf.txt"

for baseFile in baseFiles:

    decompName = startString + baseFile + endString

    tree = jd.readDot(decompName)
    root = tree.nodes()[0]
    neighbours = tree.neighbors(root)
    td.make_it_nice(tree, root, neighbours)
    graph = gf.read_edges_from_file(baseFile, " ")

    root = tree.nodes()[0]
    tree = td.get_nice_tree_decomp(tree, root)
    orderOfComputation = list(nx.dfs_postorder_nodes(tree, root))

    delValuesTable = {}
    for guy in orderOfComputation:
        print str(guy) + " has kind " + tree.node[guy][
            "kind"] + " and bag " + tree.node[guy][
                "label"] + " and neighbours " + str(tree.neighbors(guy))

    maxK = len(graph.edges())
    maxH = 6
    hSolved = False
    start1 = time.time()
Example #5
0
import treeDecomposition as td
import time
# E-mail stuff
import smtplib
INFINITY = 999999999

for i in range(6):
    # Name of the file containing edges for the graph
    GRAPHNAME = "sampleGraphs/links2012.edges-"+ str(i) +".anonGraph"
    TREENAME = "TreeDecomplinks2012.edges-" + str(i) + ".anonGraph.dgf.txt"
    #content = GRAPHNAME + "\n" + TREENAME + "\n\n"
    print "GraphName =", GRAPHNAME
    print "DecompName =", TREENAME

    treeDecomp = nx.read_dot(TREENAME)
    graph = gf.read_edges_from_file(GRAPHNAME, " ")
    root = treeDecomp.nodes()[0]
    niceTreeDecomp = td.get_nice_tree_decomp(treeDecomp, root)
    
    for j in range(graph.number_of_nodes()/8, graph.number_of_nodes()/2):
        for k in range(1, len(graph.edges())):
            print "Working on a graph with", graph.number_of_nodes(), "vertices"
            #msg = "Working on a graph with " + str(graph.number_of_nodes()) + " vertices\n"

            print "Looking for at most", k, "edges to delete, so as to"
            print "separate the graph into components of size at most", j, "nodes"
            #msg = msg + "Looking for at most " + str(k) + " edges to delete, so as to\n"
            #msg = msg + "separate the graph into components of size at most " + str(j) + " nodes\n"
            # Code to track execution time
            print "Starting search..."
            print "Calling td.apply_algorithm(graph, treeDecomp, ",j,",",k,")"