Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 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):
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 corridor(numIntersections=10, defaultNode=None, defaultEdge=None, centralReservation=0, hdistance=500):
net = network.Net(defaultNode, defaultEdge)
net.addNode(network.Node("0/1", 0, 500, "priority"))
for i in range(0, numIntersections):
net.addNode(
network.Node(str(i + 1) + "/0", (i + 1) * hdistance, 0, "priority"))
net.addNode(
network.Node(str(i + 1) + "/1", (i + 1) * hdistance, 500, "traffic_light"))
net.addNode(
network.Node(str(i + 1) + "/2", (i + 1) * hdistance, 1000, "priority"))
net.connectNodes(
str(i) + "/1", str(i + 1) + "/1", True, centralReservation)
net.connectNodes(
str(i + 1) + "/0", str(i + 1) + "/1", True, centralReservation)
net.connectNodes(
str(i + 1) + "/1", str(i + 1) + "/2", True, centralReservation)
net.addNode(network.Node(str(numIntersections + 1) + "/1",
(numIntersections + 1) * 500, 500, "priority"))