void Connect(IEdgeModel edgeModel, Experimental.GraphView.Port output, Experimental.GraphView.Port input) { var edge = new Edge(edgeModel); AddToGraphView(edge); edge.input = input; edge.output = output; edge.input.Connect(edge); edge.output.Connect(edge); m_GraphView.AddPositionDependency(edge.model); }
static void VisitNodes(Experimental.GraphView.Node node, ref HashSet <Experimental.GraphView.Node> visitedGraphElements) { if (node == null || visitedGraphElements == null || visitedGraphElements.Contains(node)) { return; } if (node is StackNode) { foreach (var visualElement in node.inputContainer.Children()) { var port = (Port)visualElement; if (port?.connections == null) { continue; } foreach (Experimental.GraphView.Edge connection in port.connections) { Experimental.GraphView.Port otherConnection = connection.output; Experimental.GraphView.Node otherNode = otherConnection?.node; if (otherNode == null) { continue; } visitedGraphElements.Add(otherNode); VisitNodes(otherNode, ref visitedGraphElements); } } } else { foreach (var visualElement in node.outputContainer.Children()) { var port = (Port)visualElement; if (port?.connections == null) { continue; } foreach (Experimental.GraphView.Edge connection in port.connections) { Experimental.GraphView.Port otherConnection = connection.input; Experimental.GraphView.Node otherNode = otherConnection?.node; if (otherNode == null) { continue; } visitedGraphElements.Add(otherNode); VisitNodes(otherNode, ref visitedGraphElements); } } } switch (node) { case FunctionNode functionNode: visitedGraphElements.Add(functionNode); break; case Node vsNode when vsNode.IsInStack: visitedGraphElements.Add(vsNode.Stack); break; } }