Open mtrberzi opened 9 years ago
So the 2 maps are (edge in G1) -> (vertex in G2) for inputs and outputs, correct? Also, is subgraph being used afterwards? (if not, I should be able to just add the vertices / edges as-is except for input/output instead of doing copy, right?) 1 more - why do we need to create new reference vertices? Is this because of scoping?
Yes, that's right.
On Sun, Feb 8, 2015 at 8:58 AM, Max Qitian Chen notifications@github.com wrote:
So the 2 maps are (edge in G1) -> (vertex in G2) for inputs and outputs, correct?
— Reply to this email directly or view it on GitHub https://github.com/manifold-lang/manifold-frontend/issues/56#issuecomment-73411851 .
Here is the specification for a useful function: (this should go in
FunctionInvocationVertex.elaborate()
or wherever primitive node instantiation is being done)Function
reconnectExpressionGraph
Input: two
ExpressionGraph
s G1 and G2, and twoMap<ExpressionEdge, VariableReferenceVertex>
s inputs and outputsPreconditions: G1 and G2 are distinct. G1 and G2 have no common vertices or edges. Every
ExpressionEdge
in inputs and outputs is in G1. EveryVariableReferenceVertex
in inputs and outputs is in G2.Functionality: This function connects G2 to G1. It first creates G2 as a subgraph inside G1. For each non-
VariableReference
vertex in G2, an identical vertex is added to G1. For eachVariableReferenceVertex
in G2, a corresponding new vertex is created in G1, with a newly-generated unique variable name. All edges in G2 that refer to aVariableReferenceVertex
are created in G1, with the source or target (as appropriate) changed to refer to the newly created vertex. All other edges in G2 are re-created in G1 with the same (isomorphic) source and target for each. Finally, for each pair ininputs
, the target of that edge in G1 is changed to refer to the newly createdVariableReferenceVertex
that corresponds to the other member of the pair; and similarly, foroutputs
, the source of that edge in G1 is changed in a similar way.