Skip to content

Commit

Permalink
Re-use cache for right side tag lookup too.
Browse files Browse the repository at this point in the history
Fix expanding edge cache entryfor undirected graphs.
  • Loading branch information
mgritter committed Dec 13, 2019
1 parent 39b0d9e commit d5bec9c
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions soffit/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def leftSide( self, leftGraph ):

if not nx.is_directed( leftGraph ):
revEdges = [ (b,a) for (a,b) in edges_matching_tag ]
edges_matching_tag += revEdges
edges_matching_tag = edges_matching_tag + revEdges

self.model.addConstraint( TupleConstraint( edges_matching_tag ), [a,b] )

Expand Down Expand Up @@ -262,17 +262,16 @@ def rightSide( self, rightGraph ):
indicators = []
# i = which graph node was picked
possible = False
for i in self.graph.nodes:

tag = self.left.nodes[n].get( 'tag', None )
nodes_matching_tag = self.nodesForTag( tag )
for (i,) in nodes_matching_tag:
# We waste a lot of time constructing these
# conditions if they're impossible anyway.
#
# We *could* just pass in a function rather than a table
# constraint, since our backend is pyconstraint. But that
# wouldn't be very portable back to a SAT-based solver.
tag = self.left.nodes[n].get( 'tag', None )
if self.graph.nodes[i].get( 'tag', None ) != tag:
continue

if nx.is_directed( self.graph ):
if self._danglingDirected( n, i ):
possible = True
Expand Down

0 comments on commit d5bec9c

Please sign in to comment.