javascriptd3.jsdagre-d3

graph.hasEdge function in dagre-d3/graphlib


Has anyone used the graph.hasEdge function in dagre-d3/graphlib to see if an edge exists between two nodes. I'm talking about an API which takes in two arguments basically the two nodes and checks if an edge exists between the two.

My problem is that for me, this function always returns false. I tried giving it for two nodes which have an edge between the two, and it still gives me a false.(Note that, it however works when you give only one argument, basically the edge id which you had defined at the time of doing graph.addEdge(edgeid, source, destination);

Please see the link to the API rerference


Solution

  • Would like to answer my question here, dagre-d3 is working on a previous version of graphlib - http://cpettitt.github.io/project/graphlib/latest/doc/index.html

    So, for the moment, the fix would be to check for a non-empty array from outEdges using the 2-arg variant:http://cpettitt.github.io/project/graphlib/latest/doc/index.html#Digraph-outEdges

    (Quoted from cpettitt : Link to the issues page - https://github.com/cpettitt/dagre-d3/issues/91)