dagrejs / dagre-d3

A D3-based renderer for Dagre
MIT License
2.85k stars 587 forks source link

graph.hasEdge function not working for two arguments #91

Open aftab-hassan opened 9 years ago

aftab-hassan commented 9 years ago

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);

Link to the graphlib api reference : https://github.com/cpettitt/graphlib/wiki/API-Reference#hasEdge

cpettitt commented 9 years ago

dagre-d3 is currently on an older version of graphlib, which has a different API. I'm working to get dagre-d3 upgraded to the new API.

In the meantime, check out the graphlib API used by dagre-d3 here: http://cpettitt.github.io/project/graphlib/latest/doc/index.html. To check if an edge exists between two nodes 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

aftab-hassan commented 9 years ago

Thanks cpettitt, that should be enough!