Graph view making an undirected graph

So, I’d like to have a graph were nodes only have one port. That is, instead of inputs and outputs, just one port that can accept connections from other ports without looking if the connection is output>input. In other words, an undirected graph.
I know there must be some function that gets called whenever the user tries to connect a node, a function that checks if the connection is valid (i.e if it’s an output>input connection) and forbids the connection that are not. I’d like to override that behaviour, but I have no clue of what’s the name of that function.
Can anyone tell me if is this possible and how could I do it?

Heya,

In your base class deriving from GraphView there’s indeed an overrideable function called GetCompatiblePorts. You can override this and perform whatever validation you’d like. In your case I think this would do the trick

public override List<Port> GetCompatiblePorts(Port startPort, NodeAdapter nodeAdapter)
        {
            return ports.ToList(); //All ports are compatible with all other ports.
        }

Mmm, weird, I’m already overriding that method and still can do it.
The only rules I have are that 1. a port can’t connect with itself. 2. a port can’t connect with any port in it’s same node.
Other than that it has no other rules for say output>otuput connections. There must be some other method.

I think is the event UnityEditor.Experimental.GraphView.Port+DefaultEdgeConnectorListener.OnDrop but I’m not sure how to override this thing

Bump

An Edge can only accept 1 input port and 1 output port as defined by the port direction. To get round this I would create a class inheriting from Edge and try to override input or output to change the default direction of that specific port.
Not sure if this will work but I think thats the only way

Of course a simple approach would be to have multiple unused input and output ports in the nodes which all ocupy the same physical space on the UI. Then you can always select an input port from one node and an output port from the other.

This seems like what I’m looking for, but is presenting a problem:
I forced the ports to ocuppy the same UI space and hide the labels, visually I have only one port now, although is really one port over the other. But by doing this I seem to loose the graphic raycaster or something, because it no longer interacts. I mean, I can’t connect anything to it or start a new connection. The debugger shows the area completly green as if it were pure padding, and it kind of is.
If only I could add a visual element like a button, and I could then call the methods for starting or ending a connection when it’s pressed, I think it would work. Not sure how to get hold of those events tough(?)