<jupyter_start><jupyter_text>Writing `Network` to MATSimLet's read in a sample MATSim network into GeNet's `Network` object.<jupyter_code>from genet import read_matsim
import os

path_to_matsim_network = '../example_data/pt2matsim_network'

network = os.path.join(path_to_matsim_network, 'network.xml')
schedule = os.path.join(path_to_matsim_network, 'schedule.xml')
vehicles = os.path.join(path_to_matsim_network, 'vehicles.xml')
n = read_matsim(
    path_to_network=network, 
    epsg='epsg:27700', 
    path_to_schedule=schedule, 
    path_to_vehicles=vehicles
)
# you don't need to read the vehicles file, but doing so ensures all vehicles
# in the schedule are of the expected type and the definition of the vehicle
# is preserved
n.print()<jupyter_output>Graph info: Name: Network graph
Type: MultiDiGraph
Number of nodes: 1662
Number of edges: 3166
Average in degree:   1.9049
Average out degree:   1.9049 
Schedule info: Schedule:
Number of services: 9
Number of unique routes: 68
Number of stops: 45<jupyter_text>To write the network into matsim format, use `write_to_matsim`<jupyter_code>n.write_to_matsim(os.path.join(path_to_matsim_network, 'genet_output'))<jupyter_output>2020-12-15 18:16:29,395 - Writing ../example_data/pt2matsim_network/genet_output/network.xml
2020-12-15 18:16:30,366 - Writing ../example_data/pt2matsim_network/genet_output/schedule.xml
2020-12-15 18:16:30,396 - Writing ../example_data/pt2matsim_network/genet_output/vehicles.xml
{'fraction_non_alphanumeric': 0.09692832764505119, 'fraction_numerical': 0.05665529010238908, 'mean_word_length': 5.882629107981221, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '573861', 'license': 'MIT', 'n_tokens_mistral': 587, 'n_tokens_neox': 519, 'n_words': 125, 'path': 'notebooks/3.1. Writing MATSim data.ipynb', 'repo_name': 'arup-group/genet', 'size': '1465'}