File tree Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -42,18 +42,21 @@ def add(self, transaction):
42
42
next_point = FPNode (self , item )
43
43
point .add (next_point )
44
44
45
- # Update the path of nodes that contain this item to include
45
+ # Update the route of nodes that contain this item to include
46
46
# our new node.
47
- try :
48
- path = self ._routes [item ]
49
- path [1 ].neighbor = next_point # path[1] is the tail
50
- path [1 ] = next_point
51
- except KeyError :
52
- # First node for this item; start a new path.
53
- self ._routes [item ] = [next_point , next_point ]
47
+ self ._update_route (next_point )
54
48
55
49
point = next_point
56
50
51
+ def _update_route (self , point ):
52
+ try :
53
+ route = self ._routes [point .item ]
54
+ route [1 ].neighbor = point # route[1] is the tail
55
+ route [1 ] = point
56
+ except KeyError :
57
+ # First node for this item; start a new route.
58
+ self ._routes [point .item ] = [point , point ]
59
+
57
60
def nodes (self , item ):
58
61
"""
59
62
Generates the sequence of nodes that contain the given item.
You can’t perform that action at this time.
0 commit comments