I've just installed Graphlab and am trying to convert NetworkX code to Graphlab. I'm having trouble finding in the Graphlab documentation the NetworkX equivalent of G.has_edge()
. If a similar function does not exist, how would one check if an Graphlab Edge already exists in the Graph?
The SGraph.get_edges
method can be used to check if a particular edge exists. In my example below I create a "chain" graph where vertices with consecutive integers are connected by an edge.
>>> import graphlab
>>> g = graphlab.SGraph().add_edges(
[graphlab.Edge(i, i+1) for i in range(4)])
# Edge does exist.
>>> test1 = g.get_edges(src_ids=[0], dst_ids=[1])
>>> test1.num_rows()
1
# Edge does *not* exist.
>>> test2 = g.get_edges(src_ids=[0], dst_ids=[2])
>>> test2.num_rows()
0
Here's the link to the API docs for get_edges
: https://dato.com/products/create/docs/generated/graphlab.SGraph.get_edges.html