BridgesUNCC / bridges-python

Python client library for Bridges
http://bridgesuncc.github.io
MIT License
3 stars 4 forks source link

list helper in graphs die if the vertex has no outgoign edges #76

Closed esaule closed 3 years ago

esaule commented 3 years ago

If you have a graph with no outgoing vertex, the out_going_edge_set_of function dies. I don't quite understand how the list_helper works, so I am not quite sure how to fix it.

Consider this code

from bridges.graph_adj_list import *
from bridges.bridges import *

bridges = Bridges(1, "YOUR_USER_ID", "YOUR_API_KEY")

#creating a 3 vertices graph with one edge.
g = GraphAdjList()
a1 = "Kevin_Bacon_(I)"
a2 = "Denzel_Washington"
a3 = "Noone"
g.add_vertex(a1, "")
g.add_vertex(a2, "")
g.add_vertex(a3, "")
g.add_edge(a1, a2)

# works
for edge in g.out_going_edge_set_of(a1):
    f = edge.fromv
    to = edge.tov

# does not work
for edge in g.out_going_edge_set_of(a2):
    f = edge.fromv
    to = edge.tov

# does not work
for edge in g.out_going_edge_set_of(a3):
    f = edge.fromv
    to = edge.tov

Here is what you get running it

$ python3 s.py
Traceback (most recent call last):
  File "s.py", line 22, in <module>
    for edge in g.out_going_edge_set_of(a2):
  File "/home/erik/work/bridges/bridges-python/bridges/sl_element.py", line 95, in list_helper
    while node.next is not None:
AttributeError: 'NoneType' object has no attribute 'next'
$
esaule commented 3 years ago

@quaiquai I think you are the one who had written that helper.

I'll add that code in the regularly run tests

esaule commented 3 years ago

@krs-world I added test in bridges-client testing to test this particular case in all three languages. Only python is having this error.