snap-python icon indicating copy to clipboard operation
snap-python copied to clipboard

GetRndNI() is not wrapped like GetNI()

Open viswajithiii opened this issue 9 years ago • 1 comments

Just flagging an issue found while working on a recent CS224W homework. Consider the following code snippet:

net = snap.GenRndGnm(snap.PUNGraph, 5, 10)
firstNI = net.GetNI(0)
randomNI = net.GetRndNI()
print firstNI  # prints snap.TUNGraphNodeI; proxy of <Swig Object of type 'TUNGraphNodeI *'
print randomNI  # prints Swig Object of type 'TUNGraph::TNodeI *'
print firstNI.GetId()  # prints 0
print randomNI.GetId()  # raises exception: AttributeError: 'SwigPyObject' object has no attribute 'GetId'

Basically, it looks get GetRndNI() does not return a snap.TUNGraphNodeI object.

I think the change is simple, and needs to be done in this file: https://github.com/snap-stanford/snap-python/blob/2f2e41559150ca790548e3d10486128ed3d84a27/dev/swig-r/pungraph.i

Let me know if you agree. I'd be happy to send in a pull request. :)

viswajithiii avatar Dec 02 '16 19:12 viswajithiii

I tried a simple wrapping and it did not work. It would be great, if you have a patch that works.

roks avatar Dec 03 '16 03:12 roks