<jupyter_start><jupyter_text>Shortest Path Between Two Nodes<jupyter_code>import networkx as nx
import matplotlib.pyplot as plt
import random
import sys
def create_network(cities, costs, num_edges):
    G = nx.Graph()
    for i in Cities:
        G.add_node(i)
    while(G.number_of_edges() < num_edges):
        c1 = random.choice(list(G.nodes()))
        c2 = random.choice(list(G.nodes()))
        if(c1 != c2 and G.has_edge(c1,c2)==0):
            w = random.choice(costs)
            G.add_edge(c1,c2,weight=w)
    return G
Cities = ['Delhi', 'Bangalore', 'Hyderabad', 'Ahmadabad', 'Channai', 'Kolkata', 'Surat', 'Pune', 'Jaipur']
costs = []
value = 100

while value <= 2000:
    costs.append(value)
    value = value + 100

print(costs)
G = create_network(Cities, costs, 10)
nx.draw(G)
u = 'Pune'
v = 'Kolkata'

print(nx.dijkstra_path(G,u,v))
print(nx.dijkstra_path(G,'Bangalore','Surat'))
nx.dijkstra_path_length(G, 'Pune', 'Kolkata')
nx.dijkstra_path_length(G, 'Surat', 'Kolkata')
nx.dijkstra_path_length(G, 'Kolkata', 'Surat')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16150234741784036, 'fraction_numerical': 0.01971830985915493, 'mean_word_length': 4.33, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '47024', 'license': 'MIT', 'n_tokens_mistral': 451, 'n_tokens_neox': 436, 'n_words': 83, 'path': '01-03-Basic_Graphs.ipynb', 'repo_name': 'SyedHamedRaza/Social_Network', 'size': '1065'}