title: Horton's algorithm I coded does not work well
body: <p>I tried coding Horton's algorithm to derive a minimum cycle basis for an unweighted undirected 2-connected graph.
  However, the basis often cover the all edges of a graph.
  I guess that the program could correctly make Horton set .
  So how to fix my code to work correctly?</p>
  
  <pre><code>for v in G.nodes():
      T = BFS_Tree(G,v)
      for x,y in G.edges():
          path_vtox = nx.shortest_path(T,source=v,target=x)
          path_vtoy = nx.shortest_path(T,source=v,target=y)
          if set(path_vtox) &amp; set(path_vtoy) == {v}:
              cycel = []
              for i in range(len(path_vtox)-1):
                  cycle.append(path_vtox[i],path_vtox[i+1])
              for i in range(len(path_vtoy)-1):
                  cycle.append(path_vtoy[i],path_vtoy[i+1])
              cycle.append((x,y))
              g = nx.Graph()
              g.add_edges_from(cycle)
              try:
                  nx.find_cycle(g)
                  Cycles.append(cycle)
              except:
                  pass
  </code></pre>