A Bellmann-Ford implementation

Goal:

  • Implement Bellmann-Ford as an asynchronous algorithm
  • Test it on actual network topologies, downloaded from TopologyZoo
  • Amended with distance-based delay
  • Visualize the graph and the algorithm execution

Setup required packages

In [91]:
import sys 

import graphviz
import pygraphviz

import networkx as nx
from geopy.distance import great_circle

from collections import defaultdict
import numpy as np
import pandas as pd
from IPython.display import display, HTML

Basic parameters

In [92]:
iterations = 30  # how many algorithm steps to show? 
speedoflight = 200000  # km/s in fibre 

A little helper class to better deal with networks

While NetworkX is pretty powerful, some of its API is a bit cumbersome. We use a little helper class to make life easier.

In [93]:
class GraphHelper():

    def __init__(self, graph=None, path=None):
        """Delegate the actual graph handling to an nx class. 
        (alternative subclassing, but a bit cumbersome to work with the 
        networkx classes)
        Setup graph attributes like distances and empty data strcutrues
        for the routing algorithm: each node gets a distvector to store 
        its currently computed distance vector and a disttable, storing 
        the distance vectors it has most recently received from all its 
        known neighbors."""

        if path:
            self.gr = nx.read_gml(path)
        else: 
            self.gr = graph
        
        self.compute_distances()

        for n, ndata in self.gr.nodes.items():
            # self.gr.nodes[n]['distvector'] = defaultdict(lambda: sys.float_info.max)
            ndata['distvector'] = defaultdict(lambda: sys.float_info.max)
            # self.gr.nodes[n]['disttable'] = dict([
            ndata['disttable'] = dict([
                (neigh, defaultdict(lambda: sys.float_info.max))
                for neigh in self.gr.neighbors(n)
                ])

            for neigh in self.gr.neighbors(n):
                ndata['disttable'][neigh][n] = self.gr[n][neigh]['weight']
                ndata['distvector'][neigh] = self.gr[n][neigh]['weight']


    def show_node(self, n):
        """Display both the current distance vector and all 
        the node's neighbors recently received distance vectors 
        in a convenient table, using panda's data frames"""
        
        tmp = self.gr.nodes[n]['disttable']
        
        # let's hope that **DV** will never appear as a node name: 
        tmp['**DV**'] = self.gr.nodes[n]['distvector']
        df = pd.DataFrame.from_dict(tmp)
        
        # display: renders the given HTML directly; df will return HTML 
        display(df)
        
    def show_nodes(self, n=None):
        # TODO: restructure; this is silly. 
        if not n:
            for nn in self.gr.nodes():
                print("Node: ", nn)
                self.show_node(nn)
        else:
            self.show_node(n)
            

    def dist_vector_arrives(self, to_node, neighbor, ):
        """Actual routing algorithm: What to do when an update
        arrives from a neighbor in the form of a new distance vector?"""

        # what do we currently know from this node? This has to be updated
        local_dist_vector = self.gr.nodes[to_node]['disttable'][neighbor]
        
        # get the neighbor's distance vector: this is what we just received: 
        arriving_dist_vector = self.gr.nodes[neighbor]['distvector']
        
        # cost between this node and the neighbor 
        cost = self.gr.edges[to_node, neighbor]['weight']

        # this node's current distance vector to all known destinations 
        # this has to be updated with information from neighbor 
        my_dist_vector = self.gr.nodes[to_node]['distvector']

        # just for illustration: say what we just know: 
        print("we learn:")
        print(list(arriving_dist_vector.items()))


        # do the update, iterate over all entries in the just received information 
        for k, v in arriving_dist_vector.items():
            
            # add code that updates the local_dist_vector 
            # and the just received one 
            # Watch out: distance vectors are defaultdicts that have max_float 
            # as default value; that should simplify your code quite a bit 
            # 
            
            ### BEGIN SOLUTION 
            local_dist_vector[k]  = v + cost
            my_dist_vector[k] = min(my_dist_vector[k], local_dist_vector[k])
            ### END SOLUTION


    def compute_distances(self):
        """For initalization, computing distances and latency 
        between all pairs of nodes. Update corresponding edge 
        attributes. """
        
        for a, b in self.gr.edges():
            node_a = self.gr.nodes[a]
            node_b = self.gr.nodes[b]
            edge = self.gr[a][b]

            # Use geopy functions to compute distance between the nodes
            # based on the Latitude and Longitude attributes of the nodes
            # Compute latency between them using speedoflight
            # store latex in the edge's weight attribute; distance in 
            # the edge's len attribute
            # Watch out: not all nodes need to have meaningful 
            # Latitude or Longitude information! 

            ### BEGIN SOLUTION 
            try: 
                dist = float(great_circle(
                    (node_a['Latitude'], node_a['Longitude']), 
                    (node_b['Latitude'], node_b['Longitude']), 
                    ).km)

                time = dist/speedoflight

                edge['weight'] = time * 1000 # ok, not SI units, but ms are just easier to read
                edge['len'] = dist 
            except:
                edge['weight'] = sys.float_info.max 
                edge['len'] = sys.float_info.max 
            ### END SOLUTION     
                
    def display(self):
        """Show the graph based on graphviz layouting"""
        tmp = nx.nx_agraph.to_agraph(self.gr)

        # better layout: too slow for Uebung 
        # tmp.layout('neato')
        # tmp.draw('neato.png')
        Gr = graphviz.Source(tmp.string())
        return Gr              

Get a graph

We load a gml description obtained from TopologyZoo (http://www.topology-zoo.org). Nice little todo: directly download from there into a file-like object... We use the NetworkX library to parse the file and to represent the network graph with its attributes.

In [94]:
# H = GraphHelper(path='Abvt.gml')
H = GraphHelper(path='Ans.gml')

Let's have a look at the graph

TODO: Put link weights into the display

In [95]:
H.display()
Out[95]:
Ans Hartford Hartford New York New York Hartford--New York Cleveland Cleveland Hartford--Cleveland New York--Cleveland Washington, DC Washington, DC New York--Washington, DC Reston Reston New York--Reston Washington, DC--Reston St Louis St Louis Reston--St Louis Dallas Dallas Reston--Dallas Dallas--St Louis Houston Houston Dallas--Houston San Jose San Jose Dallas--San Jose Chicago Chicago Chicago--Cleveland Chicago--St Louis Denver Denver Chicago--Denver San Francisco San Francisco Denver--San Francisco San Francisco--San Jose Los Angeles Los Angeles San Francisco--Los Angeles Greensboro Greensboro Greensboro--Washington, DC Atlanta Atlanta Greensboro--Atlanta Atlanta--Houston Seattle Seattle Seattle--Denver Seattle--San Francisco Albuquerque Albuquerque Los Angeles--Albuquerque Albuquerque--Houston Hawaii Hawaii Albuquerque--Hawaii
In [96]:
H.show_nodes()
Node:  Hartford
New York Cleveland **DV**
Hartford 0.803336 3.745437 NaN
New York NaN NaN 0.803336
Cleveland NaN NaN 3.745437
Node:  New York
Hartford Cleveland Washington, DC Reston **DV**
New York 0.803336 3.249581 1.642456 1.722825 NaN
Hartford NaN NaN NaN NaN 0.803336
Cleveland NaN NaN NaN NaN 3.249581
Washington, DC NaN NaN NaN NaN 1.642456
Reston NaN NaN NaN NaN 1.722825
Node:  Chicago
Cleveland St Louis Denver **DV**
Chicago 2.479979 2.092529 7.37692 NaN
Cleveland NaN NaN NaN 2.479979
St Louis NaN NaN NaN 2.092529
Denver NaN NaN NaN 7.376920
Node:  Cleveland
Hartford New York Chicago **DV**
Cleveland 3.745437 3.249581 2.479979 NaN
Hartford NaN NaN NaN 3.745437
New York NaN NaN NaN 3.249581
Chicago NaN NaN NaN 2.479979
Node:  Greensboro
Atlanta Washington, DC **DV**
Greensboro 2.461206 1.984819 NaN
Atlanta NaN NaN 2.461206
Washington, DC NaN NaN 1.984819
Node:  Atlanta
Greensboro Houston **DV**
Atlanta 2.461206 5.6378 NaN
Greensboro NaN NaN 2.461206
Houston NaN NaN 5.637800
Node:  Washington, DC
New York Greensboro Reston **DV**
Washington, DC 1.642456 1.984819 0.138 NaN
New York NaN NaN NaN 1.642456
Greensboro NaN NaN NaN 1.984819
Reston NaN NaN NaN 0.138000
Node:  Reston
New York Washington, DC Dallas St Louis **DV**
Reston 1.722825 0.138 9.395695 5.569521 NaN
New York NaN NaN NaN NaN 1.722825
Washington, DC NaN NaN NaN NaN 0.138000
Dallas NaN NaN NaN NaN 9.395695
St Louis NaN NaN NaN NaN 5.569521
Node:  Dallas
Reston St Louis San Jose Houston **DV**
Dallas 9.395695 4.408709 11.657959 1.81356 NaN
Reston NaN NaN NaN NaN 9.395695
St Louis NaN NaN NaN NaN 4.408709
San Jose NaN NaN NaN NaN 11.657959
Houston NaN NaN NaN NaN 1.813560
Node:  St Louis
Chicago Reston Dallas **DV**
St Louis 2.092529 5.569521 4.408709 NaN
Chicago NaN NaN NaN 2.092529
Reston NaN NaN NaN 5.569521
Dallas NaN NaN NaN 4.408709
Node:  Seattle
Denver San Francisco **DV**
Seattle 8.205592 5.466066 NaN
Denver NaN NaN 8.205592
San Francisco NaN NaN 5.466066
Node:  Denver
Chicago Seattle San Francisco **DV**
Denver 7.37692 8.205592 7.624922 NaN
Chicago NaN NaN NaN 7.376920
Seattle NaN NaN NaN 8.205592
San Francisco NaN NaN NaN 7.624922
Node:  San Francisco
Seattle Denver San Jose Los Angeles **DV**
San Francisco 5.466066 7.624922 0.334765 2.795618 NaN
Seattle NaN NaN NaN NaN 5.466066
Denver NaN NaN NaN NaN 7.624922
San Jose NaN NaN NaN NaN 0.334765
Los Angeles NaN NaN NaN NaN 2.795618
Node:  San Jose
Dallas San Francisco **DV**
San Jose 11.657959 0.334765 NaN
Dallas NaN NaN 11.657959
San Francisco NaN NaN 0.334765
Node:  Los Angeles
San Francisco Albuquerque **DV**
Los Angeles 2.795618 5.335134 NaN
San Francisco NaN NaN 2.795618
Albuquerque NaN NaN 5.335134
Node:  Albuquerque
Los Angeles Hawaii Houston **DV**
Albuquerque 5.335134 25.934801 6.061707 NaN
Los Angeles NaN NaN NaN 5.335134
Hawaii NaN NaN NaN 25.934801
Houston NaN NaN NaN 6.061707
Node:  Hawaii
Albuquerque **DV**
Hawaii 25.934801 NaN
Albuquerque NaN 25.934801
Node:  Houston
Atlanta Dallas Albuquerque **DV**
Houston 5.6378 1.81356 6.061707 NaN
Atlanta NaN NaN NaN 5.637800
Dallas NaN NaN NaN 1.813560
Albuquerque NaN NaN NaN 6.061707

Run Bellmann-Ford for a few iterations

For each iteration, select an edge along which we assume a distance vector is sent. Receiving nodes updates its information from this node and compares it to its current best to see if there is any improvement.

In [97]:
edge_list = list(H.gr.edges.items())

for i in range(iterations):
    ri = np.random.randint(0, len(edge_list)-1)
    # watch out: randint includes BOTH lower and upper limt, 
    # hence, the -1! 
    
    from_node, to_node = edge_list[ri][0]
    
    print("#######################")
    print(from_node, " -->> ", to_node)

    print("Old information at ", to_node)
    H.show_nodes(to_node)
    
    H.dist_vector_arrives(to_node, from_node)
    
    print("Updated information at ", to_node)
    H.show_nodes(to_node)
#######################
New York  -->>  Cleveland
Old information at  Cleveland
Hartford New York Chicago **DV**
Cleveland 3.745437 3.249581 2.479979 NaN
Hartford NaN NaN NaN 3.745437
New York NaN NaN NaN 3.249581
Chicago NaN NaN NaN 2.479979
we learn:
[('Hartford', 0.8033363109285977), ('Cleveland', 3.2495814000326164), ('Washington, DC', 1.6424559338115634), ('Reston', 1.7228246781547314)]
Updated information at  Cleveland
Hartford New York Chicago **DV**
Cleveland 3.745437 6.499163 2.479979 6.499163
Hartford NaN 4.052918 NaN 3.745437
Washington, DC NaN 4.892037 NaN 4.892037
Reston NaN 4.972406 NaN 4.972406
New York NaN NaN NaN 3.249581
Chicago NaN NaN NaN 2.479979
#######################
Los Angeles  -->>  Albuquerque
Old information at  Albuquerque
Los Angeles Hawaii Houston **DV**
Albuquerque 5.335134 25.934801 6.061707 NaN
Los Angeles NaN NaN NaN 5.335134
Hawaii NaN NaN NaN 25.934801
Houston NaN NaN NaN 6.061707
we learn:
[('San Francisco', 2.7956184539968745), ('Albuquerque', 5.335133927863918)]
Updated information at  Albuquerque
Los Angeles Hawaii Houston **DV**
Albuquerque 10.670268 25.934801 6.061707 10.670268
San Francisco 8.130752 NaN NaN 8.130752
Los Angeles NaN NaN NaN 5.335134
Hawaii NaN NaN NaN 25.934801
Houston NaN NaN NaN 6.061707
#######################
San Francisco  -->>  Los Angeles
Old information at  Los Angeles
San Francisco Albuquerque **DV**
Los Angeles 2.795618 5.335134 NaN
San Francisco NaN NaN 2.795618
Albuquerque NaN NaN 5.335134
we learn:
[('Seattle', 5.466065553672212), ('Denver', 7.624922108867412), ('San Jose', 0.3347653138003973), ('Los Angeles', 2.7956184539968745)]
Updated information at  Los Angeles
San Francisco Albuquerque **DV**
Los Angeles 5.591237 5.335134 5.591237
Seattle 8.261684 NaN 8.261684
Denver 10.420541 NaN 10.420541
San Jose 3.130384 NaN 3.130384
San Francisco NaN NaN 2.795618
Albuquerque NaN NaN 5.335134
#######################
Greensboro  -->>  Atlanta
Old information at  Atlanta
Greensboro Houston **DV**
Atlanta 2.461206 5.6378 NaN
Greensboro NaN NaN 2.461206
Houston NaN NaN 5.637800
we learn:
[('Atlanta', 2.461206107195715), ('Washington, DC', 1.984819481540269)]
Updated information at  Atlanta
Greensboro Houston **DV**
Atlanta 4.922412 5.6378 4.922412
Washington, DC 4.446026 NaN 4.446026
Greensboro NaN NaN 2.461206
Houston NaN NaN 5.637800
#######################
New York  -->>  Reston
Old information at  Reston
New York Washington, DC Dallas St Louis **DV**
Reston 1.722825 0.138 9.395695 5.569521 NaN
New York NaN NaN NaN NaN 1.722825
Washington, DC NaN NaN NaN NaN 0.138000
Dallas NaN NaN NaN NaN 9.395695
St Louis NaN NaN NaN NaN 5.569521
we learn:
[('Hartford', 0.8033363109285977), ('Cleveland', 3.2495814000326164), ('Washington, DC', 1.6424559338115634), ('Reston', 1.7228246781547314)]
Updated information at  Reston
New York Washington, DC Dallas St Louis **DV**
Reston 3.445649 0.138 9.395695 5.569521 3.445649
Hartford 2.526161 NaN NaN NaN 2.526161
Cleveland 4.972406 NaN NaN NaN 4.972406
Washington, DC 3.365281 NaN NaN NaN 0.138000
New York NaN NaN NaN NaN 1.722825
Dallas NaN NaN NaN NaN 9.395695
St Louis NaN NaN NaN NaN 5.569521
#######################
Dallas  -->>  St Louis
Old information at  St Louis
Chicago Reston Dallas **DV**
St Louis 2.092529 5.569521 4.408709 NaN
Chicago NaN NaN NaN 2.092529
Reston NaN NaN NaN 5.569521
Dallas NaN NaN NaN 4.408709
we learn:
[('Reston', 9.3956948947631), ('St Louis', 4.4087091494527435), ('San Jose', 11.657958903000226), ('Houston', 1.813559592557177)]
Updated information at  St Louis
Chicago Reston Dallas **DV**
St Louis 2.092529 5.569521 8.817418 8.817418
Reston NaN NaN 13.804404 5.569521
San Jose NaN NaN 16.066668 16.066668
Houston NaN NaN 6.222269 6.222269
Chicago NaN NaN NaN 2.092529
Dallas NaN NaN NaN 4.408709
#######################
Greensboro  -->>  Atlanta
Old information at  Atlanta
Greensboro Houston **DV**
Atlanta 4.922412 5.6378 4.922412
Washington, DC 4.446026 NaN 4.446026
Greensboro NaN NaN 2.461206
Houston NaN NaN 5.637800
we learn:
[('Atlanta', 2.461206107195715), ('Washington, DC', 1.984819481540269)]
Updated information at  Atlanta
Greensboro Houston **DV**
Atlanta 4.922412 5.6378 4.922412
Washington, DC 4.446026 NaN 4.446026
Greensboro NaN NaN 2.461206
Houston NaN NaN 5.637800
#######################
Albuquerque  -->>  Hawaii
Old information at  Hawaii
Albuquerque **DV**
Hawaii 25.934801 NaN
Albuquerque NaN 25.934801
we learn:
[('Los Angeles', 5.335133927863918), ('Hawaii', 25.934800961177434), ('Houston', 6.0617067772607935), ('San Francisco', 8.130752381860793), ('Albuquerque', 10.670267855727836)]
Updated information at  Hawaii
Albuquerque **DV**
Hawaii 51.869602 51.869602
Los Angeles 31.269935 31.269935
Houston 31.996508 31.996508
San Francisco 34.065553 34.065553
Albuquerque 36.605069 25.934801
#######################
Seattle  -->>  Denver
Old information at  Denver
Chicago Seattle San Francisco **DV**
Denver 7.37692 8.205592 7.624922 NaN
Chicago NaN NaN NaN 7.376920
Seattle NaN NaN NaN 8.205592
San Francisco NaN NaN NaN 7.624922
we learn:
[('Denver', 8.205591689370896), ('San Francisco', 5.466065553672212)]
Updated information at  Denver
Chicago Seattle San Francisco **DV**
Denver 7.37692 16.411183 7.624922 16.411183
San Francisco NaN 13.671657 NaN 7.624922
Chicago NaN NaN NaN 7.376920
Seattle NaN NaN NaN 8.205592
#######################
Los Angeles  -->>  Albuquerque
Old information at  Albuquerque
Los Angeles Hawaii Houston **DV**
Albuquerque 10.670268 25.934801 6.061707 10.670268
San Francisco 8.130752 NaN NaN 8.130752
Los Angeles NaN NaN NaN 5.335134
Hawaii NaN NaN NaN 25.934801
Houston NaN NaN NaN 6.061707
we learn:
[('San Francisco', 2.7956184539968745), ('Albuquerque', 5.335133927863918), ('Seattle', 8.261684007669086), ('Denver', 10.420540562864286), ('San Jose', 3.1303837677972717), ('Los Angeles', 5.591236907993749)]
Updated information at  Albuquerque
Los Angeles Hawaii Houston **DV**
Albuquerque 10.670268 25.934801 6.061707 10.670268
San Francisco 8.130752 NaN NaN 8.130752
Seattle 13.596818 NaN NaN 13.596818
Denver 15.755674 NaN NaN 15.755674
San Jose 8.465518 NaN NaN 8.465518
Los Angeles 10.926371 NaN NaN 5.335134
Hawaii NaN NaN NaN 25.934801
Houston NaN NaN NaN 6.061707
#######################
Dallas  -->>  Houston
Old information at  Houston
Atlanta Dallas Albuquerque **DV**
Houston 5.6378 1.81356 6.061707 NaN
Atlanta NaN NaN NaN 5.637800
Dallas NaN NaN NaN 1.813560
Albuquerque NaN NaN NaN 6.061707
we learn:
[('Reston', 9.3956948947631), ('St Louis', 4.4087091494527435), ('San Jose', 11.657958903000226), ('Houston', 1.813559592557177)]
Updated information at  Houston
Atlanta Dallas Albuquerque **DV**
Houston 5.6378 3.627119 6.061707 3.627119
Reston NaN 11.209254 NaN 11.209254
St Louis NaN 6.222269 NaN 6.222269
San Jose NaN 13.471518 NaN 13.471518
Atlanta NaN NaN NaN 5.637800
Dallas NaN NaN NaN 1.813560
Albuquerque NaN NaN NaN 6.061707
#######################
Washington, DC  -->>  Reston
Old information at  Reston
New York Washington, DC Dallas St Louis **DV**
Reston 3.445649 0.138 9.395695 5.569521 3.445649
Hartford 2.526161 NaN NaN NaN 2.526161
Cleveland 4.972406 NaN NaN NaN 4.972406
Washington, DC 3.365281 NaN NaN NaN 0.138000
New York NaN NaN NaN NaN 1.722825
Dallas NaN NaN NaN NaN 9.395695
St Louis NaN NaN NaN NaN 5.569521
we learn:
[('New York', 1.6424559338115634), ('Greensboro', 1.984819481540269), ('Reston', 0.13800047951505537)]
Updated information at  Reston
New York Washington, DC Dallas St Louis **DV**
Reston 3.445649 0.276001 9.395695 5.569521 0.276001
Hartford 2.526161 NaN NaN NaN 2.526161
Cleveland 4.972406 NaN NaN NaN 4.972406
Washington, DC 3.365281 NaN NaN NaN 0.138000
New York NaN 1.780456 NaN NaN 1.722825
Greensboro NaN 2.122820 NaN NaN 2.122820
Dallas NaN NaN NaN NaN 9.395695
St Louis NaN NaN NaN NaN 5.569521
#######################
Greensboro  -->>  Washington, DC
Old information at  Washington, DC
New York Greensboro Reston **DV**
Washington, DC 1.642456 1.984819 0.138 NaN
New York NaN NaN NaN 1.642456
Greensboro NaN NaN NaN 1.984819
Reston NaN NaN NaN 0.138000
we learn:
[('Atlanta', 2.461206107195715), ('Washington, DC', 1.984819481540269)]
Updated information at  Washington, DC
New York Greensboro Reston **DV**
Washington, DC 1.642456 3.969639 0.138 3.969639
Atlanta NaN 4.446026 NaN 4.446026
New York NaN NaN NaN 1.642456
Greensboro NaN NaN NaN 1.984819
Reston NaN NaN NaN 0.138000
#######################
Dallas  -->>  St Louis
Old information at  St Louis
Chicago Reston Dallas **DV**
St Louis 2.092529 5.569521 8.817418 8.817418
Reston NaN NaN 13.804404 5.569521
San Jose NaN NaN 16.066668 16.066668
Houston NaN NaN 6.222269 6.222269
Chicago NaN NaN NaN 2.092529
Dallas NaN NaN NaN 4.408709
we learn:
[('Reston', 9.3956948947631), ('St Louis', 4.4087091494527435), ('San Jose', 11.657958903000226), ('Houston', 1.813559592557177)]
Updated information at  St Louis
Chicago Reston Dallas **DV**
St Louis 2.092529 5.569521 8.817418 8.817418
Reston NaN NaN 13.804404 5.569521
San Jose NaN NaN 16.066668 16.066668
Houston NaN NaN 6.222269 6.222269
Chicago NaN NaN NaN 2.092529
Dallas NaN NaN NaN 4.408709
#######################
New York  -->>  Washington, DC
Old information at  Washington, DC
New York Greensboro Reston **DV**
Washington, DC 1.642456 3.969639 0.138 3.969639
Atlanta NaN 4.446026 NaN 4.446026
New York NaN NaN NaN 1.642456
Greensboro NaN NaN NaN 1.984819
Reston NaN NaN NaN 0.138000
we learn:
[('Hartford', 0.8033363109285977), ('Cleveland', 3.2495814000326164), ('Washington, DC', 1.6424559338115634), ('Reston', 1.7228246781547314)]
Updated information at  Washington, DC
New York Greensboro Reston **DV**
Washington, DC 3.284912 3.969639 0.138 3.284912
Hartford 2.445792 NaN NaN 2.445792
Cleveland 4.892037 NaN NaN 4.892037
Reston 3.365281 NaN NaN 0.138000
Atlanta NaN 4.446026 NaN 4.446026
New York NaN NaN NaN 1.642456
Greensboro NaN NaN NaN 1.984819
#######################
Albuquerque  -->>  Hawaii
Old information at  Hawaii
Albuquerque **DV**
Hawaii 51.869602 51.869602
Los Angeles 31.269935 31.269935
Houston 31.996508 31.996508
San Francisco 34.065553 34.065553
Albuquerque 36.605069 25.934801
we learn:
[('Los Angeles', 5.335133927863918), ('Hawaii', 25.934800961177434), ('Houston', 6.0617067772607935), ('San Francisco', 8.130752381860793), ('Albuquerque', 10.670267855727836), ('Seattle', 13.596817935533004), ('Denver', 15.755674490728204), ('San Jose', 8.46551769566119)]
Updated information at  Hawaii
Albuquerque **DV**
Hawaii 51.869602 51.869602
Los Angeles 31.269935 31.269935
Houston 31.996508 31.996508
San Francisco 34.065553 34.065553
Albuquerque 36.605069 25.934801
Seattle 39.531619 39.531619
Denver 41.690475 41.690475
San Jose 34.400319 34.400319
#######################
Chicago  -->>  St Louis
Old information at  St Louis
Chicago Reston Dallas **DV**
St Louis 2.092529 5.569521 8.817418 8.817418
Reston NaN NaN 13.804404 5.569521
San Jose NaN NaN 16.066668 16.066668
Houston NaN NaN 6.222269 6.222269
Chicago NaN NaN NaN 2.092529
Dallas NaN NaN NaN 4.408709
we learn:
[('Cleveland', 2.479979105238593), ('St Louis', 2.0925290157213063), ('Denver', 7.376919918280654)]
Updated information at  St Louis
Chicago Reston Dallas **DV**
St Louis 4.185058 5.569521 8.817418 4.185058
Cleveland 4.572508 NaN NaN 4.572508
Denver 9.469449 NaN NaN 9.469449
Reston NaN NaN 13.804404 5.569521
San Jose NaN NaN 16.066668 16.066668
Houston NaN NaN 6.222269 6.222269
Chicago NaN NaN NaN 2.092529
Dallas NaN NaN NaN 4.408709
#######################
Dallas  -->>  San Jose
Old information at  San Jose
Dallas San Francisco **DV**
San Jose 11.657959 0.334765 NaN
Dallas NaN NaN 11.657959
San Francisco NaN NaN 0.334765
we learn:
[('Reston', 9.3956948947631), ('St Louis', 4.4087091494527435), ('San Jose', 11.657958903000226), ('Houston', 1.813559592557177)]
Updated information at  San Jose
Dallas San Francisco **DV**
San Jose 23.315918 0.334765 23.315918
Reston 21.053654 NaN 21.053654
St Louis 16.066668 NaN 16.066668
Houston 13.471518 NaN 13.471518
Dallas NaN NaN 11.657959
San Francisco NaN NaN 0.334765
#######################
Greensboro  -->>  Washington, DC
Old information at  Washington, DC
New York Greensboro Reston **DV**
Washington, DC 3.284912 3.969639 0.138 3.284912
Hartford 2.445792 NaN NaN 2.445792
Cleveland 4.892037 NaN NaN 4.892037
Reston 3.365281 NaN NaN 0.138000
Atlanta NaN 4.446026 NaN 4.446026
New York NaN NaN NaN 1.642456
Greensboro NaN NaN NaN 1.984819
we learn:
[('Atlanta', 2.461206107195715), ('Washington, DC', 1.984819481540269)]
Updated information at  Washington, DC
New York Greensboro Reston **DV**
Washington, DC 3.284912 3.969639 0.138 3.284912
Hartford 2.445792 NaN NaN 2.445792
Cleveland 4.892037 NaN NaN 4.892037
Reston 3.365281 NaN NaN 0.138000
Atlanta NaN 4.446026 NaN 4.446026
New York NaN NaN NaN 1.642456
Greensboro NaN NaN NaN 1.984819
#######################
Seattle  -->>  San Francisco
Old information at  San Francisco
Seattle Denver San Jose Los Angeles **DV**
San Francisco 5.466066 7.624922 0.334765 2.795618 NaN
Seattle NaN NaN NaN NaN 5.466066
Denver NaN NaN NaN NaN 7.624922
San Jose NaN NaN NaN NaN 0.334765
Los Angeles NaN NaN NaN NaN 2.795618
we learn:
[('Denver', 8.205591689370896), ('San Francisco', 5.466065553672212)]
Updated information at  San Francisco
Seattle Denver San Jose Los Angeles **DV**
San Francisco 10.932131 7.624922 0.334765 2.795618 10.932131
Denver 13.671657 NaN NaN NaN 7.624922
Seattle NaN NaN NaN NaN 5.466066
San Jose NaN NaN NaN NaN 0.334765
Los Angeles NaN NaN NaN NaN 2.795618
#######################
Seattle  -->>  Denver
Old information at  Denver
Chicago Seattle San Francisco **DV**
Denver 7.37692 16.411183 7.624922 16.411183
San Francisco NaN 13.671657 NaN 7.624922
Chicago NaN NaN NaN 7.376920
Seattle NaN NaN NaN 8.205592
we learn:
[('Denver', 8.205591689370896), ('San Francisco', 5.466065553672212)]
Updated information at  Denver
Chicago Seattle San Francisco **DV**
Denver 7.37692 16.411183 7.624922 16.411183
San Francisco NaN 13.671657 NaN 7.624922
Chicago NaN NaN NaN 7.376920
Seattle NaN NaN NaN 8.205592
#######################
San Francisco  -->>  San Jose
Old information at  San Jose
Dallas San Francisco **DV**
San Jose 23.315918 0.334765 23.315918
Reston 21.053654 NaN 21.053654
St Louis 16.066668 NaN 16.066668
Houston 13.471518 NaN 13.471518
Dallas NaN NaN 11.657959
San Francisco NaN NaN 0.334765
we learn:
[('Seattle', 5.466065553672212), ('Denver', 7.624922108867412), ('San Jose', 0.3347653138003973), ('Los Angeles', 2.7956184539968745), ('San Francisco', 10.932131107344423)]
Updated information at  San Jose
Dallas San Francisco **DV**
San Jose 23.315918 0.669531 0.669531
Reston 21.053654 NaN 21.053654
St Louis 16.066668 NaN 16.066668
Houston 13.471518 NaN 13.471518
Seattle NaN 5.800831 5.800831
Denver NaN 7.959687 7.959687
Los Angeles NaN 3.130384 3.130384
San Francisco NaN 11.266896 0.334765
Dallas NaN NaN 11.657959
#######################
Seattle  -->>  San Francisco
Old information at  San Francisco
Seattle Denver San Jose Los Angeles **DV**
San Francisco 10.932131 7.624922 0.334765 2.795618 10.932131
Denver 13.671657 NaN NaN NaN 7.624922
Seattle NaN NaN NaN NaN 5.466066
San Jose NaN NaN NaN NaN 0.334765
Los Angeles NaN NaN NaN NaN 2.795618
we learn:
[('Denver', 8.205591689370896), ('San Francisco', 5.466065553672212)]
Updated information at  San Francisco
Seattle Denver San Jose Los Angeles **DV**
San Francisco 10.932131 7.624922 0.334765 2.795618 10.932131
Denver 13.671657 NaN NaN NaN 7.624922
Seattle NaN NaN NaN NaN 5.466066
San Jose NaN NaN NaN NaN 0.334765
Los Angeles NaN NaN NaN NaN 2.795618
#######################
New York  -->>  Reston
Old information at  Reston
New York Washington, DC Dallas St Louis **DV**
Reston 3.445649 0.276001 9.395695 5.569521 0.276001
Hartford 2.526161 NaN NaN NaN 2.526161
Cleveland 4.972406 NaN NaN NaN 4.972406
Washington, DC 3.365281 NaN NaN NaN 0.138000
New York NaN 1.780456 NaN NaN 1.722825
Greensboro NaN 2.122820 NaN NaN 2.122820
Dallas NaN NaN NaN NaN 9.395695
St Louis NaN NaN NaN NaN 5.569521
we learn:
[('Hartford', 0.8033363109285977), ('Cleveland', 3.2495814000326164), ('Washington, DC', 1.6424559338115634), ('Reston', 1.7228246781547314)]
Updated information at  Reston
New York Washington, DC Dallas St Louis **DV**
Reston 3.445649 0.276001 9.395695 5.569521 0.276001
Hartford 2.526161 NaN NaN NaN 2.526161
Cleveland 4.972406 NaN NaN NaN 4.972406
Washington, DC 3.365281 NaN NaN NaN 0.138000
New York NaN 1.780456 NaN NaN 1.722825
Greensboro NaN 2.122820 NaN NaN 2.122820
Dallas NaN NaN NaN NaN 9.395695
St Louis NaN NaN NaN NaN 5.569521
#######################
Seattle  -->>  San Francisco
Old information at  San Francisco
Seattle Denver San Jose Los Angeles **DV**
San Francisco 10.932131 7.624922 0.334765 2.795618 10.932131
Denver 13.671657 NaN NaN NaN 7.624922
Seattle NaN NaN NaN NaN 5.466066
San Jose NaN NaN NaN NaN 0.334765
Los Angeles NaN NaN NaN NaN 2.795618
we learn:
[('Denver', 8.205591689370896), ('San Francisco', 5.466065553672212)]
Updated information at  San Francisco
Seattle Denver San Jose Los Angeles **DV**
San Francisco 10.932131 7.624922 0.334765 2.795618 10.932131
Denver 13.671657 NaN NaN NaN 7.624922
Seattle NaN NaN NaN NaN 5.466066
San Jose NaN NaN NaN NaN 0.334765
Los Angeles NaN NaN NaN NaN 2.795618
#######################
Hartford  -->>  New York
Old information at  New York
Hartford Cleveland Washington, DC Reston **DV**
New York 0.803336 3.249581 1.642456 1.722825 NaN
Hartford NaN NaN NaN NaN 0.803336
Cleveland NaN NaN NaN NaN 3.249581
Washington, DC NaN NaN NaN NaN 1.642456
Reston NaN NaN NaN NaN 1.722825
we learn:
[('New York', 0.8033363109285977), ('Cleveland', 3.745437160054054)]
Updated information at  New York
Hartford Cleveland Washington, DC Reston **DV**
New York 1.606673 3.249581 1.642456 1.722825 1.606673
Cleveland 4.548773 NaN NaN NaN 3.249581
Hartford NaN NaN NaN NaN 0.803336
Washington, DC NaN NaN NaN NaN 1.642456
Reston NaN NaN NaN NaN 1.722825
#######################
Hartford  -->>  New York
Old information at  New York
Hartford Cleveland Washington, DC Reston **DV**
New York 1.606673 3.249581 1.642456 1.722825 1.606673
Cleveland 4.548773 NaN NaN NaN 3.249581
Hartford NaN NaN NaN NaN 0.803336
Washington, DC NaN NaN NaN NaN 1.642456
Reston NaN NaN NaN NaN 1.722825
we learn:
[('New York', 0.8033363109285977), ('Cleveland', 3.745437160054054)]
Updated information at  New York
Hartford Cleveland Washington, DC Reston **DV**
New York 1.606673 3.249581 1.642456 1.722825 1.606673
Cleveland 4.548773 NaN NaN NaN 3.249581
Hartford NaN NaN NaN NaN 0.803336
Washington, DC NaN NaN NaN NaN 1.642456
Reston NaN NaN NaN NaN 1.722825
#######################
Seattle  -->>  Denver
Old information at  Denver
Chicago Seattle San Francisco **DV**
Denver 7.37692 16.411183 7.624922 16.411183
San Francisco NaN 13.671657 NaN 7.624922
Chicago NaN NaN NaN 7.376920
Seattle NaN NaN NaN 8.205592
we learn:
[('Denver', 8.205591689370896), ('San Francisco', 5.466065553672212)]
Updated information at  Denver
Chicago Seattle San Francisco **DV**
Denver 7.37692 16.411183 7.624922 16.411183
San Francisco NaN 13.671657 NaN 7.624922
Chicago NaN NaN NaN 7.376920
Seattle NaN NaN NaN 8.205592
#######################
Washington, DC  -->>  Reston
Old information at  Reston
New York Washington, DC Dallas St Louis **DV**
Reston 3.445649 0.276001 9.395695 5.569521 0.276001
Hartford 2.526161 NaN NaN NaN 2.526161
Cleveland 4.972406 NaN NaN NaN 4.972406
Washington, DC 3.365281 NaN NaN NaN 0.138000
New York NaN 1.780456 NaN NaN 1.722825
Greensboro NaN 2.122820 NaN NaN 2.122820
Dallas NaN NaN NaN NaN 9.395695
St Louis NaN NaN NaN NaN 5.569521
we learn:
[('New York', 1.6424559338115634), ('Greensboro', 1.984819481540269), ('Reston', 0.13800047951505537), ('Atlanta', 4.446025588735984), ('Washington, DC', 3.284911867623127), ('Hartford', 2.445792244740161), ('Cleveland', 4.89203733384418)]
Updated information at  Reston
New York Washington, DC Dallas St Louis **DV**
Reston 3.445649 0.276001 9.395695 5.569521 0.276001
Hartford 2.526161 2.583793 NaN NaN 2.526161
Cleveland 4.972406 5.030038 NaN NaN 4.972406
Washington, DC 3.365281 3.422912 NaN NaN 0.138000
New York NaN 1.780456 NaN NaN 1.722825
Greensboro NaN 2.122820 NaN NaN 2.122820
Atlanta NaN 4.584026 NaN NaN 4.584026
Dallas NaN NaN NaN NaN 9.395695
St Louis NaN NaN NaN NaN 5.569521
#######################
Washington, DC  -->>  Reston
Old information at  Reston
New York Washington, DC Dallas St Louis **DV**
Reston 3.445649 0.276001 9.395695 5.569521 0.276001
Hartford 2.526161 2.583793 NaN NaN 2.526161
Cleveland 4.972406 5.030038 NaN NaN 4.972406
Washington, DC 3.365281 3.422912 NaN NaN 0.138000
New York NaN 1.780456 NaN NaN 1.722825
Greensboro NaN 2.122820 NaN NaN 2.122820
Atlanta NaN 4.584026 NaN NaN 4.584026
Dallas NaN NaN NaN NaN 9.395695
St Louis NaN NaN NaN NaN 5.569521
we learn:
[('New York', 1.6424559338115634), ('Greensboro', 1.984819481540269), ('Reston', 0.13800047951505537), ('Atlanta', 4.446025588735984), ('Washington, DC', 3.284911867623127), ('Hartford', 2.445792244740161), ('Cleveland', 4.89203733384418)]
Updated information at  Reston
New York Washington, DC Dallas St Louis **DV**
Reston 3.445649 0.276001 9.395695 5.569521 0.276001
Hartford 2.526161 2.583793 NaN NaN 2.526161
Cleveland 4.972406 5.030038 NaN NaN 4.972406
Washington, DC 3.365281 3.422912 NaN NaN 0.138000
New York NaN 1.780456 NaN NaN 1.722825
Greensboro NaN 2.122820 NaN NaN 2.122820
Atlanta NaN 4.584026 NaN NaN 4.584026
Dallas NaN NaN NaN NaN 9.395695
St Louis NaN NaN NaN NaN 5.569521