1 changed files with 106 additions and 0 deletions
@ -0,0 +1,106 @@ |
|||||
|
import networkx as nx |
||||
|
from pyvis.network import Network |
||||
|
|
||||
|
def main(): |
||||
|
G = nx.DiGraph() |
||||
|
|
||||
|
for i in range(1,25): |
||||
|
G.add_node(f'Route {i}', node_type='route') |
||||
|
|
||||
|
G.add_node('Pallet Town', node_type='location') |
||||
|
G.add_node('Viridian City', node_type='location') |
||||
|
G.add_node('Viridian Forest', node_type='location') |
||||
|
G.add_node('Pewter City', node_type='location') |
||||
|
G.add_node('Mt. Moon', node_type='location') |
||||
|
G.add_node('Cerulean City', node_type='location') |
||||
|
G.add_node('Power Plant', node_type='location') |
||||
|
G.add_node('Saffron City', node_type='location') |
||||
|
G.add_node('Celadon City', node_type='location') |
||||
|
G.add_node('Cerulean Cave', node_type='location') |
||||
|
G.add_node('Vermillion City', node_type='location') |
||||
|
G.add_node('Fuchsia City', node_type='location') |
||||
|
G.add_node('Cinnabar Island', node_type='location') |
||||
|
G.add_node('Seafoam Islands', node_type='location') |
||||
|
G.add_node('Victory Road', node_type='location') |
||||
|
G.add_node('Indigo Plateau', node_type='location') |
||||
|
G.add_node('Rock Tunnel', node_type='location') |
||||
|
G.add_node('Underground Path', node_type='location') |
||||
|
|
||||
|
G.add_edge('Pallet Town', 'Route 1', condition=None) |
||||
|
G.add_edge('Pallet Town', 'Route 21', condition=None) |
||||
|
G.add_edge('Route 1', 'Viridian City', condition=None) |
||||
|
G.add_edge('Viridian City', 'Route 2', condition=None) |
||||
|
G.add_edge('Route 2', 'Viridian Forest', condition=None) |
||||
|
G.add_edge('Viridian Forest', 'Pewter City', condition=None) |
||||
|
G.add_edge('Pewter City', 'Route 3', condition=None) |
||||
|
G.add_edge('Route 3', 'Mt. Moon', condition=None) |
||||
|
G.add_edge('Mt. Moon', 'Route 4', condition=None) |
||||
|
G.add_edge('Route 4', 'Cerulean City', condition=None) |
||||
|
G.add_edge('Cerulean City', 'Route 24', condition=None) |
||||
|
G.add_edge('Cerulean City', 'Route 9', condition=None) |
||||
|
G.add_edge('Cerulean City', 'Route 5', condition=None) |
||||
|
G.add_edge('Route 5', 'Saffron City', condition=None) |
||||
|
G.add_edge('Saffron City', 'Route 6', condition=None) |
||||
|
G.add_edge('Saffron City', 'Route 7', condition=None) |
||||
|
G.add_edge('Saffron City', 'Route 8', condition=None) |
||||
|
G.add_edge('Route 6', 'Vermillion City', condition=None) |
||||
|
G.add_edge('Vermillion City', 'Route 11', condition=None) |
||||
|
G.add_edge('Route 11', 'Route 12', condition=None) |
||||
|
G.add_edge('Route 12', 'Route 13', condition=None) |
||||
|
G.add_edge('Route 12', 'Lavender Town', condition=None) |
||||
|
G.add_edge('Route 7', 'Lavender Town', condition=None) |
||||
|
G.add_edge('Route 9', 'Route 10', condition=None) |
||||
|
G.add_edge('Route 10', 'Rock Tunnel', condition=None) |
||||
|
G.add_edge('Lavender Town', 'Rock Tunnel', condition=None) |
||||
|
G.add_edge('Celadon City', 'Route 8', condition=None) |
||||
|
G.add_edge('Celadon City', 'Route 16', condition=None) |
||||
|
G.add_edge('Route 16', 'Route 17', condition=None) |
||||
|
G.add_edge('Route 17', 'Route 18', condition=None) |
||||
|
G.add_edge('Route 18', 'Fuchsia City', condition=None) |
||||
|
G.add_edge('Fuchsia City','Route 19', condition=None) |
||||
|
G.add_edge('Fuchsia City','Route 15', condition=None) |
||||
|
G.add_edge('Fuchsia City','Safari Zone', condition=None) |
||||
|
G.add_edge('Route 19', 'Seafoam Islands', condition=None) |
||||
|
G.add_edge('Seafoam Islands', 'Route 20', condition=None) |
||||
|
G.add_edge('Route 20', 'Cinnabar Island', condition=None) |
||||
|
G.add_edge('Route 21', 'Cinnabar Island', condition=None) |
||||
|
G.add_edge('Route 22', 'Viridian City', condition=None) |
||||
|
G.add_edge('Route 22', 'Route 23', condition=None) |
||||
|
G.add_edge('Route 23', 'Victory Road', condition=None) |
||||
|
G.add_edge('Victory Road', 'Indigo Plateau', condition=None) |
||||
|
G.add_edge('Route 12', 'Route 13', condition=None) |
||||
|
G.add_edge('Route 13', 'Route 14', condition=None) |
||||
|
G.add_edge('Route 14', 'Route 15', condition=None) |
||||
|
G.add_edge('Route 24', 'Cerulean Cave', condition=None) |
||||
|
G.add_edge('Route 10', 'Power Plant', condition=None) |
||||
|
G.add_edge('Route 5', 'Underground Path', condition=None) |
||||
|
G.add_edge('Underground Path', 'Route 6', condition=None) |
||||
|
|
||||
|
net = Network(notebook=True) |
||||
|
for node, attrs in G.nodes(data=True): |
||||
|
net.add_node( |
||||
|
node, |
||||
|
label=node, |
||||
|
title=f"Type: {attrs}", |
||||
|
color='lightblue' if attrs == 'location' else 'lightgreen' |
||||
|
) |
||||
|
|
||||
|
for source, target, attrs in G.edges(data=True): |
||||
|
condition = attrs['condition'] |
||||
|
edge_label = f"Condition: {condition}" if condition else "No condition" |
||||
|
net.add_edge( |
||||
|
source, |
||||
|
target, |
||||
|
title=edge_label, |
||||
|
label=edge_label, |
||||
|
color='red' if condition else 'gray' |
||||
|
) |
||||
|
|
||||
|
net.show('pokemon_map.html') |
||||
|
|
||||
|
|
||||
|
if __name__ == "__main__": |
||||
|
try: |
||||
|
main() |
||||
|
finally: |
||||
|
pass |
||||
Loading…
Reference in new issue