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
| train_style.append({'selector': 'node[classes="EU"]', | |
| 'style': {'background-color': 'orange'}}) | |
| train_style.append({'selector': 'edge[classes="EU"]', | |
| 'style': {'font-family': 'arial', | |
| 'font-size': '10px', | |
| 'label': 'data(label)'}}) | |
| ipycytoscape_obj3 = ipycytoscape.CytoscapeWidget() | |
| ipycytoscape_obj3.graph.add_graph_from_json(railnetJSON) | |
| ipycytoscape_obj3.graph.add_node(station_NUR) | |
| ipycytoscape_obj3.graph.add_edges([new_edge1,new_edge2]) |
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
| EU_stations = ['PAR','MIL','BAR','LYO'] | |
| new_EU_stations = [] | |
| for station in EU_stations: | |
| new_station = ipycytoscape.Node() | |
| new_station.data['id'] = station | |
| new_station.data['label'] = f"CS {station}" # CS = Central Station | |
| new_station.data['classes'] = "EU" | |
| new_EU_stations.append(new_station) | |
| connections = [('BER','PAR'),('PAR','LYO'),('LYO','BAR'),('LYO','MIL')] |
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
| ipycytoscape_obj2.graph.nodes | |
| for node in ipycytoscape_obj2.graph.nodes: | |
| if node.data['id'] == 'NUR': | |
| node.data['label'] = 'Hbf NUR' | |
| ipycytoscape_obj2 |
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
| train_style.append({'selector': 'edge[id = "line6"]', | |
| 'style': { | |
| 'font-family': 'arial', | |
| 'font-size': '10px', | |
| 'label': 'data(label)'}}) | |
| train_style.append({'selector': 'edge[id = "line7"]', | |
| 'style': { | |
| 'font-family': 'arial', | |
| 'font-size': '10px', | |
| 'label': 'data(label)'}}) |
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
| # rail connection NUR-LEP | |
| new_edge1 = ipycytoscape.Edge() | |
| new_edge1.data['id'] = "line6" | |
| new_edge1.data['source'] = "NUR" | |
| new_edge1.data['target'] = "LEP" | |
| new_edge1.data['label'] = "150km/h" | |
| # rail connection NUR-FRA | |
| new_edge2 = ipycytoscape.Edge() | |
| new_edge2.data['id'] = "line7" |
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
| station_NUR = ipycytoscape.Node() | |
| station_NUR.data['id'] = "NUR" | |
| station_NUR.data['label'] = "HBf NUR in construction" | |
| station_NUR.data['classes'] = "west" | |
| ipycytoscape_obj.graph.add_node(station_NUR) | |
| ipycytoscape_obj |
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
| import ipycytoscape | |
| import json | |
| import ipywidgets | |
| # I paste here allthe data in order to allow you to copy and paste it without loading data from files. | |
| railnet= '''{ | |
| "nodes": [ | |
| {"data": { "id": "BER", "label":"HBf BER", "classes":"east"}}, | |
| {"data": { "id": "MUN", "label":"HBf MUN", "classes":"west"}}, | |
| {"data": { "id": "FRA", "label":"HBf FRA", "classes":"west"}}, | |
| {"data": { "id": "HAM", "label":"HBf HAM", "classes":"west"}}, |
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
| train_style.append({'selector': 'node[classes="EU"]', | |
| 'style': {'background-color': 'orange'}}) | |
| train_style.append({'selector': 'edge[classes="EU"]', | |
| 'style': {'font-family': 'arial', | |
| 'font-size': '10px', | |
| 'label': 'data(label)'}}) | |
| ipycytoscape_obj3 = ipycytoscape.CytoscapeWidget() | |
| ipycytoscape_obj3.graph.add_graph_from_json(railnetJSON) | |
| ipycytoscape_obj3.graph.add_node(station_NUR) | |
| ipycytoscape_obj3.graph.add_edges([new_edge1,new_edge2]) |
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
| EU_stations = ['PAR','MIL','BAR','LYO'] | |
| new_EU_stations = [] | |
| for station in EU_stations: | |
| new_station = ipycytoscape.Node() | |
| new_station.data['id'] = station | |
| new_station.data['label'] = f"CS {station}" # CS = Central Station | |
| new_station.data['classes'] = "EU" | |
| new_EU_stations.append(new_station) | |
| connections = [('BER','PAR'),('PAR','LYO'),('LYO','BAR'),('LYO','MIL')] |
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
| ipycytoscape_obj2.graph.nodes | |
| for node in ipycytoscape_obj2.graph.nodes: | |
| if node.data['id'] == 'NUR': | |
| node.data['label'] = 'Hbf NUR' | |
| ipycytoscape_obj2 |