Created
July 10, 2020 17:13
-
-
Save LuizDoPc/73e58b3998585d3e551fb2e17db14c23 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| COLORS = {"LARANJA": 1, "VERDE": 2, "AZUL": 3, "VERMELHO": 4} | |
| class edge: | |
| v1 = 0 | |
| v2 = 0 | |
| class vertex: | |
| id =0 | |
| colors = [] | |
| class color: | |
| value = 0 | |
| qtd = 0 | |
| class graph: | |
| edges = [] | |
| vertexes = [] | |
| def getGraph(): | |
| numVertex = int(input()) | |
| vecVertex = [] | |
| for i in range(numVertex): | |
| v = vertex() | |
| v.id, numColors = map(int, input().split()) | |
| for j in range(numColors): | |
| c = color() | |
| c.value = COLORS[input()] | |
| c.qtd = int(input()) | |
| v.colors.append(c) | |
| vecVertex.append(v) | |
| vecEdge = [] | |
| numEdges = int(input()) | |
| for i in range(numEdges): | |
| e = edge() | |
| v1, v2 = map(int, input().split()) | |
| for j in range(len(vecVertex)): | |
| if vecVertex[j].id == v1: | |
| e.v1 = vecVertex[j] | |
| if vecVertex[j].id == v2: | |
| e.v2 = vecVertex[j] | |
| vecEdge.append(e) | |
| g = graph() | |
| g.edges = vecEdge | |
| g.vertexes = vecVertex | |
| return g | |
| from gurobipy import * | |
| model = Model('Graph model') | |
| g = getGraph() | |
| print(g) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 8 | |
| 0 2 | |
| LARANJA | |
| 1 | |
| VERMELHO | |
| 2 | |
| 1 2 | |
| VERDE | |
| 1 | |
| LARANJA | |
| 2 | |
| 2 3 | |
| VERMELHO | |
| 1 | |
| VERDE | |
| 2 | |
| LARANJA | |
| 2 | |
| 3 2 | |
| LARANJA | |
| 1 | |
| VERMELHO | |
| 2 | |
| 4 2 | |
| AZUL | |
| 1 | |
| VERMELHO | |
| 1 | |
| 5 2 | |
| AZUL | |
| 2 | |
| VERDE | |
| 1 | |
| 6 3 | |
| VERMELHO | |
| 1 | |
| AZUL | |
| 2 | |
| VERDE | |
| 2 | |
| 7 3 | |
| AZUL | |
| 1 | |
| VERDE | |
| 2 | |
| VERMELHO | |
| 1 | |
| 13 | |
| 0 1 | |
| 0 2 | |
| 0 6 | |
| 1 6 | |
| 1 2 | |
| 2 6 | |
| 2 3 | |
| 2 7 | |
| 3 7 | |
| 3 4 | |
| 4 5 | |
| 5 7 | |
| 5 6 | |
| 6 7 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment