code: def hub_scores(msm, waypoints=None):
      
  
      n_states = msm.n_states_
      if isinstance(waypoints, int):
          waypoints = [waypoints]
      elif waypoints is None:
          waypoints = xrange(n_states)
      elif not (isinstance(waypoints, list) or
                isinstance(waypoints, np.ndarray)):
          raise ValueError("waypoints (%s) must be an int, a list, or None" %
                           str(waypoints))
  
      hub_scores = []
      for waypoint in waypoints:
          other_states = (i for i in xrange(n_states) if i != waypoint)
  
          # calculate the hub score for this waypoint
          hub_score = 0.0
          for (source, sink) in itertools.permutations(other_states, 2):
              hub_score += fraction_visited(source, sink, waypoint, msm)
  
          hub_score /= float((n_states - 1) * (n_states - 2))
          hub_scores.append(hub_score)
  
      return np.array(hub_scores)
docs: Calculate the hub score for one or more waypoints
  
      The "hub score" is a measure of how well traveled a certain state or
      set of states is in a network. Specifically, it is the fraction of
      times that a walker visits a state en route from some state A to another
      state B, averaged over all combinations of A and B.
  
  
      Parameters
      ----------
      msm : msmbuilder.MarkovStateModel
          MSM to analyze
      waypoints : array_like, int, optional
          The index of the intermediate state (or more than one).
          If None, then all waypoints will be used
  
      Returns
      -------
      hub_score : float
          The hub score for the waypoint
  
      References
      ----------
      .. [1] Dickson & Brooks (2012), J. Chem. Theory Comput., 8, 3044-3052.