almende / vis

⚠️ This project is not maintained anymore! Please go to https://github.com/visjs
7.85k stars 1.48k forks source link

network.getConnectedNodes with bidirected arrows #4167

Open clayt85 opened 5 years ago

clayt85 commented 5 years ago

If I have something like the following:

nodes = new vis.DataSet([{id: 1, label:'Node 1'},{id: 2, label:'Node 2'}]);
edges = new vis.DataSet([{from: 1, to: 2, arrows:'to, from'}]);

Then network.getConnectedNodes(1,'to') will return 2, but network.getConnectedNodes(1,'from') returns empty. The converse holds true for the node with id:2. It appears the getConnectedNodes() method is relying on the "from" and "to" fields of the edge data, but not taking into account the arrow type?

Meanwhile, it seems (from the documentation) that getConnectedNodes() does not support a "to, from" direction?

Loxxe commented 5 years ago

network.getConnectedNodes(1,'from') return nothing because u dont have an edge that connects to Node 1. You need to have another edge like {from: 2, to : 1}.

clayt85 commented 5 years ago

I understand why network.getConnectedNodes(1,'from') returns nothing. The issue (in my opinion) is that the edge (in the code above) is specified to be bi-directional. Yet the second argument of the getConnectedNodes() method does not allow for an input of the form "to, from".

This has a workaround (I have already implemented it) but seems like an obvious missing feature.