sumolib.net.generator.cross

 1#!/usr/bin/env python
 2# Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
 3# Copyright (C) 2013-2026 German Aerospace Center (DLR) and others.
 4# This program and the accompanying materials are made available under the
 5# terms of the Eclipse Public License 2.0 which is available at
 6# https://www.eclipse.org/legal/epl-2.0/
 7# This Source Code may also be made available under the following Secondary
 8# Licenses when the conditions for such availability set forth in the Eclipse
 9# Public License 2.0 are satisfied: GNU General Public License, version 2
10# or later which is available at
11# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13
14# @file    cross.py
15# @author  Daniel Krajzewicz
16# @date    2013-10-10
17
18from __future__ import absolute_import
19# relative imports don't work if a file is used as a library and executable
20# (https://peps.python.org/pep-0366/#rationale-for-change)
21import os
22import sys
23sys.path.append(os.path.dirname(os.path.realpath(__file__)))
24import network  # noqa
25
26
27def cross(defaultNode=None, defaultEdge=None, centralReservation=0):
28    net = network.Net(defaultNode, defaultEdge)
29    net.addNode(network.Node("1/0", 500, 0, "priority"))
30    net.addNode(network.Node("0/1", 0, 500, "priority"))
31    net.addNode(network.Node("1/1", 500, 500, "traffic_light"))
32    net.addNode(network.Node("2/1", 1000, 500, "priority"))
33    net.addNode(network.Node("1/2", 500, 1000, "priority"))
34    net.connectNodes("1/0", "1/1", True, centralReservation)
35    net.connectNodes("0/1", "1/1", True, centralReservation)
36    net.connectNodes("2/1", "1/1", True, centralReservation)
37    net.connectNodes("1/2", "1/1", True, centralReservation)
38    return net
39
40
41if __name__ == "__main__":
42    net = cross()
43    net.build()
def cross(defaultNode=None, defaultEdge=None, centralReservation=0):
28def cross(defaultNode=None, defaultEdge=None, centralReservation=0):
29    net = network.Net(defaultNode, defaultEdge)
30    net.addNode(network.Node("1/0", 500, 0, "priority"))
31    net.addNode(network.Node("0/1", 0, 500, "priority"))
32    net.addNode(network.Node("1/1", 500, 500, "traffic_light"))
33    net.addNode(network.Node("2/1", 1000, 500, "priority"))
34    net.addNode(network.Node("1/2", 500, 1000, "priority"))
35    net.connectNodes("1/0", "1/1", True, centralReservation)
36    net.connectNodes("0/1", "1/1", True, centralReservation)
37    net.connectNodes("2/1", "1/1", True, centralReservation)
38    net.connectNodes("1/2", "1/1", True, centralReservation)
39    return net