Last active
November 22, 2020 19:13
-
-
Save joseberlines/b4af93cc8d165e1cd58003f33258a325 to your computer and use it in GitHub Desktop.
graph8
This file contains 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
railnet= '''{ | |
"nodes": [ | |
{"data": { "id": "BER", "label":"HBf BER"}}, | |
{"data": { "id": "MUN", "label":"HBf MUN"}}, | |
{"data": { "id": "FRA", "label":"HBf FRA"}}, | |
{"data": { "id": "HAM", "label":"HBf HAM"}} | |
], | |
"edges": [ | |
{"data": { "id": "line1", "source": "BER", "target": "MUN","label":"200km/h"}}, | |
{"data": { "id": "line2", "source": "MUN", "target": "FRA","label":"200km/h"}}, | |
{"data": { "id": "line3", "source": "FRA", "target": "BER","label":"250km/h" }}, | |
{"data": { "id": "line4", "source": "BER", "target": "HAM","label":"300km/h" }} | |
] | |
}''' | |
my_style = [ | |
{'selector': 'node','style': { | |
'font-family': 'arial', | |
'font-size': '10px', | |
'label': 'data(label)', | |
'background-color': 'red'}}, | |
{'selector': 'node[id = "BER"]','style': { | |
'font-family': 'arial', | |
'font-size': '10px', | |
'label': 'data(label)', | |
'background-color': 'green'}}, | |
{'selector': 'edge[id = "line1"]','style': { | |
'font-family': 'arial', | |
'font-size': '10px', | |
'label': 'data(label)',}}, | |
{'selector': 'edge[id = "line2"]','style': { | |
'font-family': 'arial', | |
'font-size': '10px', | |
'label': 'data(label)',}}, | |
{'selector': 'edge[id = "line3"]','style': { | |
'font-family': 'arial', | |
'font-size': '10px', | |
'label': 'data(label)',}}, | |
{'selector': 'edge[id = "line4"]','style': { | |
'font-family': 'arial', | |
'font-size': '10px', | |
'label': 'data(label)',}} | |
] | |
railnetJSON = json.loads(railnet) | |
ipycytoscape_obj8 = ipycytoscape.CytoscapeWidget() | |
ipycytoscape_obj8.graph.add_graph_from_json(railnetJSON, directed=True) # I am telling I dont want directions | |
ipycytoscape_obj8.set_style(my_style) | |
ipycytoscape_obj8.set_style(my_style) | |
ipycytoscape_obj8 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment