Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def cross(defaultNode=None, defaultEdge=None, centralReservation=0):
net = network.Net(defaultNode, defaultEdge)
net.addNode(network.Node("1/0", 500, 0, "priority"))
net.addNode(network.Node("0/1", 0, 500, "priority"))
net.addNode(network.Node("1/1", 500, 500, "traffic_light"))
net.addNode(network.Node("2/1", 1000, 500, "priority"))
net.addNode(network.Node("1/2", 500, 1000, "priority"))
net.connectNodes("1/0", "1/1", True, centralReservation)
net.connectNodes("0/1", "1/1", True, centralReservation)
net.connectNodes("2/1", "1/1", True, centralReservation)
net.connectNodes("1/2", "1/1", True, centralReservation)
return net
def grid(numIntersectionsX=10, numIntersectionsY=5, defaultNode=None, defaultEdge=None, centralReservation=0):
net = network.Net(defaultNode, defaultEdge)
for x in range(0, numIntersectionsX):
net.addNode(
network.Node(str(x + 1) + "/0", (x + 1) * 500, 0, "priority"))
net.addNode(network.Node(str(x + 1) + "/" + str(numIntersectionsY + 1),
(x + 1) * 500, (numIntersectionsY + 1) * 500, "priority"))
for y in range(0, numIntersectionsY):
net.addNode(
network.Node("0/" + str(y + 1), 0, (y + 1) * 500, "priority"))
net.addNode(network.Node(str(numIntersectionsX + 1) + "/" +
str(y + 1), (numIntersectionsX + 1) * 500, (y + 1) * 500, "priority"))
for x in range(0, numIntersectionsX):
for y in range(0, numIntersectionsY):
net.addNode(network.Node(
str(x + 1) + "/" + str(y + 1), (x + 1) * 500, (y + 1) * 500, "traffic_light"))
for x in range(0, numIntersectionsX):
for y in range(0, numIntersectionsY):
net.connectNodes(str(
x) + "/" + str(y + 1), str(x + 1) + "/" + str(y + 1), True, centralReservation)
net.connectNodes(str(
x + 1) + "/" + str(y), str(x + 1) + "/" + str(y + 1), True, centralReservation)
for x in range(0, numIntersectionsX):
net.connectNodes(str(x + 1) + "/" + str(numIntersectionsY),
str(x + 1) + "/" + str(numIntersectionsY + 1), True, centralReservation)
for y in range(0, numIntersectionsY):
def straight(defaultNode=None, defaultEdge=None, centralReservation=0):
net = network.Net(defaultNode, defaultEdge)
net.addNode(network.Node("0/1", 0, 500, "priority"))
net.addNode(network.Node("1/1", 500, 500, "traffic_light"))
net.addNode(network.Node("2/1", 1000, 500, "priority"))
net.connectNodes("0/1", "1/1", True, centralReservation)
net.connectNodes("2/1", "1/1", True, centralReservation)
return net
# d = demand.Demand()
def cross(defaultNode=None, defaultEdge=None, centralReservation=0):
net = network.Net(defaultNode, defaultEdge)
net.addNode(network.Node("1/0", 500, 0, "priority"))
net.addNode(network.Node("0/1", 0, 500, "priority"))
net.addNode(network.Node("1/1", 500, 500, "traffic_light"))
net.addNode(network.Node("2/1", 1000, 500, "priority"))
net.addNode(network.Node("1/2", 500, 1000, "priority"))
net.connectNodes("1/0", "1/1", True, centralReservation)
net.connectNodes("0/1", "1/1", True, centralReservation)
net.connectNodes("2/1", "1/1", True, centralReservation)
net.connectNodes("1/2", "1/1", True, centralReservation)
return net
def cross(defaultNode=None, defaultEdge=None, centralReservation=0):
net = network.Net(defaultNode, defaultEdge)
net.addNode(network.Node("1/0", 500, 0, "priority"))
net.addNode(network.Node("0/1", 0, 500, "priority"))
net.addNode(network.Node("1/1", 500, 500, "traffic_light"))
net.addNode(network.Node("2/1", 1000, 500, "priority"))
net.addNode(network.Node("1/2", 500, 1000, "priority"))
net.connectNodes("1/0", "1/1", True, centralReservation)
net.connectNodes("0/1", "1/1", True, centralReservation)
net.connectNodes("2/1", "1/1", True, centralReservation)
net.connectNodes("1/2", "1/1", True, centralReservation)
return net
def grid(numIntersectionsX=10, numIntersectionsY=5, defaultNode=None, defaultEdge=None, centralReservation=0):
net = network.Net(defaultNode, defaultEdge)
for x in range(0, numIntersectionsX):
net.addNode(
network.Node(str(x + 1) + "/0", (x + 1) * 500, 0, "priority"))
net.addNode(network.Node(str(x + 1) + "/" + str(numIntersectionsY + 1),
(x + 1) * 500, (numIntersectionsY + 1) * 500, "priority"))
for y in range(0, numIntersectionsY):
net.addNode(
network.Node("0/" + str(y + 1), 0, (y + 1) * 500, "priority"))
net.addNode(network.Node(str(numIntersectionsX + 1) + "/" +
str(y + 1), (numIntersectionsX + 1) * 500, (y + 1) * 500, "priority"))
for x in range(0, numIntersectionsX):
for y in range(0, numIntersectionsY):
net.addNode(network.Node(
str(x + 1) + "/" + str(y + 1), (x + 1) * 500, (y + 1) * 500, "traffic_light"))
for x in range(0, numIntersectionsX):
for y in range(0, numIntersectionsY):
net.connectNodes(str(
x) + "/" + str(y + 1), str(x + 1) + "/" + str(y + 1), True, centralReservation)
net.connectNodes(str(
x + 1) + "/" + str(y), str(x + 1) + "/" + str(y + 1), True, centralReservation)
def grid(numIntersectionsX=10, numIntersectionsY=5, defaultNode=None, defaultEdge=None, centralReservation=0):
net = network.Net(defaultNode, defaultEdge)
for x in range(0, numIntersectionsX):
net.addNode(
network.Node(str(x + 1) + "/0", (x + 1) * 500, 0, "priority"))
net.addNode(network.Node(str(x + 1) + "/" + str(numIntersectionsY + 1),
(x + 1) * 500, (numIntersectionsY + 1) * 500, "priority"))
for y in range(0, numIntersectionsY):
net.addNode(
network.Node("0/" + str(y + 1), 0, (y + 1) * 500, "priority"))
net.addNode(network.Node(str(numIntersectionsX + 1) + "/" +
str(y + 1), (numIntersectionsX + 1) * 500, (y + 1) * 500, "priority"))
for x in range(0, numIntersectionsX):
for y in range(0, numIntersectionsY):
net.addNode(network.Node(
str(x + 1) + "/" + str(y + 1), (x + 1) * 500, (y + 1) * 500, "traffic_light"))
for x in range(0, numIntersectionsX):
for y in range(0, numIntersectionsY):
net.connectNodes(str(
x) + "/" + str(y + 1), str(x + 1) + "/" + str(y + 1), True, centralReservation)
net.connectNodes(str(
def cross(defaultNode=None, defaultEdge=None, centralReservation=0):
net = network.Net(defaultNode, defaultEdge)
net.addNode(network.Node("1/0", 500, 0, "priority"))
net.addNode(network.Node("0/1", 0, 500, "priority"))
net.addNode(network.Node("1/1", 500, 500, "traffic_light"))
net.addNode(network.Node("2/1", 1000, 500, "priority"))
net.addNode(network.Node("1/2", 500, 1000, "priority"))
net.connectNodes("1/0", "1/1", True, centralReservation)
net.connectNodes("0/1", "1/1", True, centralReservation)
net.connectNodes("2/1", "1/1", True, centralReservation)
net.connectNodes("1/2", "1/1", True, centralReservation)
return net