Exemple #1
0
def graphFromCombinations(combinations):
    resultingCombinations = []
    for comb in combinations:
        maxSumm = 0
        for v in comb:
            summ = 0
            for k in v:
                val = k.split('-')
                summ = summ+int(val[1])
            if summ > maxSumm:
                maxSumm = summ

        igraph = generateGraph([comb], False)
        resultingCombinations.append(igraph)
    return resultingCombinations
 def __init__(self,
              type,
              num_nodes,
              num_classes=3472,
              graph_type="WS",
              num_neighbors=4,
              probability=0.5):
     super(Network, self).__init__()
     self.start = keras.layers.DepthwiseConv2D(3, strides=2)
     self.batch = keras.layers.BatchNormalization()
     if type == "small":
         self.stage_start = TripletBlock(strides=2)
         graph = generator.generateGraph(graph_type, num_nodes,
                                         num_neighbors, probability)
         generator.drawGraph(graph)
         self.stage = Stage(graph)
         graph = generator.generateGraph(graph_type, num_nodes,
                                         num_neighbors, probability)
         generator.drawGraph(graph)
         self.stage2 = Stage(graph)
         graph = generator.generateGraph(graph_type, num_nodes,
                                         num_neighbors, probability)
         generator.drawGraph(graph)
         self.stage3 = Stage(graph)
         self.relu = keras.layers.ReLU()
         self.conv = keras.layers.Conv2D(109 * 4, 1)
         self.batch2 = keras.layers.BatchNormalization()
     elif type == "normal":
         graph = generator.generateGraph(graph_type, num_nodes,
                                         num_neighbors, probability)
         generator.drawGraph(graph)
         self.stage_start = Stage(graph)
         graph = generator.generateGraph(graph_type, num_nodes,
                                         num_neighbors, probability)
         generator.drawGraph(graph)
         self.stage = Stage(graph)
         graph = generator.generateGraph(graph_type, num_nodes,
                                         num_neighbors, probability)
         generator.drawGraph(graph)
         self.stage2 = Stage(graph)
         graph = generator.generateGraph(graph_type, num_nodes,
                                         num_neighbors, probability)
         generator.drawGraph(graph)
         self.stage3 = Stage(graph)
         self.relu = keras.layers.ReLU()
         self.conv = keras.layers.Conv2D(109 * 4, 1)
         self.batch2 = keras.layers.BatchNormalization()
     self.avrg = keras.layers.AveragePooling2D(7, 1)
     self.end = keras.layers.Dense(num_classes)
Exemple #3
0
def menu(option, mazematrix):
    maze = graph.generateGraph(mazematrix, mazeWidth, mazeHeight)
    if option > 6 or option < 1:
        print "Incorrect parameter: \n1 <= Option <= 4"
        sys.exit(2)
    elif option == 1:
        DFS(maze, mazematrix)
    elif option == 2:
        BFS(maze, mazematrix)
    elif option == 3:
        greedy(maze, mazematrix)
    elif option == 4:
        aStar(maze, mazematrix)
    elif option == 5:
        pacmanv1(maze, mazematrix, dots)
    elif option == 6:
        pacmanv2(maze, mazematrix, dots)
def simulatedAnnealingAlgorithm(cell, pml_layers):
    plotArray, plotScore, plotTesting, scoreArray = graph.generateGraph(
        np.zeros((grid.xPixels, grid.yPixels)), initialScore=np.zeros(100))
    testingWavelengths = wavelengthsInNMToTest()
    testingFrequencies = [
        wavelengthInNMToFrequency(x) for x in testingWavelengths
    ]
    print(arrayStorage.numberOfEntriesInDatabase())
    if (arrayStorage.numberOfEntriesInDatabase() == 0):
        #generate a random solution
        photonicGrid = initializePhotonicGrid()
        #calculate cost using cost function
        initialcost = calculateCost(cell, photonicGrid, pml_layers)
        arrayStorage.addNumpyArray(photonicGrid, initialcost)

    temperature = simulation.initialTemperature
    while temperature > simulation.finalTemperatureCutoff:
        #generate a random neighboring solution
        currentBestArray = arrayStorage.returnMostRecentNumpyArray()
        if (temperature % 10 == 0):
            currentBestArray = randomPhotonicGrid()
        x = np.random.randint(0, grid.xPixels)
        y = np.random.randint(0, grid.yPixels)
        if (currentBestArray[x, y] == 0):
            testArray = currentBestArray
            testArray[x, y] = 1
        elif (currentBestArray[x, y] == 1):
            testArray = currentBestArray
            testArray[x, y] = 0
        else:
            print("Error occured, array element was not 0 or 1")
        graph.update_testing_plot(plotTesting, testArray)
        testCost = calculateCost(cell, testArray, pml_layers)
        print("The test cost is ", testCost)
        #compare
        if (testCost > arrayStorage.returnBestCost()):
            arrayStorage.addNumpyArray(testArray, testCost)
            graph.update_plot(plotArray, testArray)
            graph.update_score(plotScore, testCost, scoreArray)
Exemple #5
0
def get_grid_graph(n):
    '''
    Construct a grid graph using graph.py
    '''
    nodes = gm.generateGraph(n, int(math.sqrt(n)) + 4, int(math.sqrt(n)) + 4, CONNECTIVITY)
    return convert_graph(gm.get_graph_representation(nodes))
Exemple #6
0
from dbpedia import strictQueryInfluencedBy, queryInfluencedAndInfluencedBy, queryInfluencedAndInfluencedByFor
from graph import generateGraph, saveToFile
from graphviz import Digraph

#Non-strict influenced and influencedBy
result = queryInfluencedAndInfluencedBy()
dot = generateGraph(result,
                    Digraph(filename="../output/programming", format="svg"))
saveToFile(dot)

#Strict influenced and influencedBy
result = strictQueryInfluencedBy()
dot = generateGraph(
    result, Digraph(filename="../output/programming-strict", format="svg"))
saveToFile(dot)

#Influenced and influencedBy for the programmming language Java
result = queryInfluencedAndInfluencedByFor("Java (programming language)")
dot = generateGraph(result, Digraph(filename="../output/java", format="svg"))
saveToFile(dot)
Exemple #7
0
for (i,arg) in enumerate(sys.argv):
	if arg == '-d':
		deb = True
	elif arg == '-g':
		graph = True
	elif arg == '-i':
		manualIn = True
	elif arg == '-o':
		manualOut = True
	elif i != 0:
		read(sys.argv[i])


# testuru = list(raw_input("kk:").upper())

if manualIn == True:
	input = manualInputOutput("input:")
if manualOut == True:
	output = manualInputOutput("output:")

init_factsValue(facts, input)
init_factsRules(facts, rules)

if deb == True:
	debug()
if graph == True:
	generateGraph(facts, input, output)

for res in output:
	print "" + res + " -> " + str( facts[res].searchValue( facts ) )
Exemple #8
0
import graph as gr
import networkx as nx

esquizofrenia = "fechou as 5 empresas e então a geração de renda e as pessoas que moravam lá eu conheço bem porque eu cresci lá são muito pequenas, são pequenas de personalidade."
control = "aí eu disse pra menina que estava comigo, eu estou vendo tudo pela metade, ela disse oxente, eu disse é... ela me deu a agenda pra eu ligar pro pessoal que ligou pra mim."
esquizofrenia = gr.prepare(esquizofrenia)
control = gr.prepare(control)
Esquigraph = gr.generateGraph(esquizofrenia)
Controlgraph = gr.generateGraph(control)
file = open("graph_visualization.txt", 'w')
nodes = []
for i in Esquigraph.edges:
    string1 = ""
    string2 = ""
    node1 = i[0]
    node2 = i[1]
    if not (node1 in nodes):
        nodes.append(node1)

    string1 = str(nodes.index(node1) + 1)

    if not (node2 in nodes):
        nodes.append(node2)

    string2 = str(nodes.index(node2) + 1)

    file.write(string1 + "-" + string2 + ",")

file.write(str(len(Esquigraph.edges)) + "\n")

nodes = []
Exemple #9
0
def main():
    datadict = io_ply.read_ply(sys.argv[1])
    original_data = io_ply.read_ply(sys.argv[2])

    generateGraph(datadict, original_data)