Git Product home page Git Product logo

snap-python's Introduction

snap-python

  1. Install SWIG for your platform (see below). Swig should be able to run from the command-line.

  2. Checkout the snap-python repository as well as the SNAP C++ repository.

     git clone [email protected]:snap-stanford/snap-python.git
     git clone [email protected]:snap-stanford/snap.git
    
  3. Then, run make from the top-level of snap-python. This will make the SNAP code into a Python module, using SWIG. Finally, it will run some Python tests in the test directory.

     cd snap-python
     make
    

    From a Python interpreter, you should be able to import snap module:

     $ python
     >>> import sys
     >>> sys.path.append("swig")
     >>> import snap
    
  4. There are some examples in the examples directory. For example, to run benchmarks:

     $ cd examples
     $ python benchmark.py -h
     usage: benchmark.py [-h] [-v] [-r RANGE] [-e EDGES_DEG] [-d] [-t GRAPH_TYPES]
                         [-n NUM_ITERATIONS] [-o OUTPUT_FILE] [-g] [-w]
    
     optional arguments:
       -h, --help            show this help message and exit
       -v, --verbose         increase output verbosity
       -r RANGE, --range RANGE
                             range (4-6) (10^4 to 10^6 nodes)
       -e EDGES_DEG, --edges_deg EDGES_DEG
                             range of degrees (e.g "2-3" => (10^1 to 10^3 edges per
                             node)
       -d, --deterministic   deterministic benchmark
       -t GRAPH_TYPES, --graph_types GRAPH_TYPES
                             Graph types, comma separated. Available: rand_ungraph,
                             rand_ngraph, rmat, pref, sw
       -n NUM_ITERATIONS, --num_iterations NUM_ITERATIONS
                             number of iterations
       -o OUTPUT_FILE, --output_file OUTPUT_FILE
                             file to output results
       -g, --generate        generate new graphs
       -w, --write_graph     save graph
     $ python benchmark.py -v -g -r 4-6	# needs about 4.3GB RAM and 4 min to run
    

SWIG Installation

Linux

Follow the instructions from SWIG's website: download, configure and make, SWIG files. Or, use your built-in installer (a CentOS example):

sudo yum install swig

Mac OS X

swig-1.3.12 and later support OS-X/Darwin.

  1. If you have homebrew, simply hit brew install swig in terminal and ignore the rest of the instructions. Otherwise, download the Unix sources, configure, and build from the command terminal. This has been tested on 10.8.2. The following is adopted from ColourBlomb.

  2. Download the Unix source from http://swig.org/download.html

  3. Moving to the terminal, extract the files from the tarball and move to the root directory of the SWIG install:

     cd /Developer/SWIG
     tar -xf swig-2.0.4.tar.gz
     cd swig-2.0.4
    
  4. Run ./configure. This will produce an error if you don't have the PCRE (Perl Compatible Regular Expressions) library package installed. This dependency is needed for configure to complete. Either:

    • Install the PCRE developer package on your system (preferred approach).

    • Download the PCRE source tarball, build and install on your system as you would for any package built from source distribution.

    • Use the Tools/pcre-build.sh script to build PCRE just for SWIG to statically link against. Run Tools/pcre-build.sh -help for instructions. (quite easy and does not require privileges to install PCRE on your system)

    • Configure using the -without-pcre option to disable regular expressions support in SWIG (not recommended). See config.log for more details.

        make
        sudo make install
      
  5. PCRE should now have successfully installed so move to the swig install directory and try ./configure again:

     cd ../swig-2.0.4
     ./configure
    

    This time no errors are thrown so try and install:

     make
     sudo make install
    
  6. Once this has completed test that SWIG has installed correctly, type swig into the terminal and hopefully you'll get the response: Must specify an input file. Use -help for available options.

SWIG Benchmarks

Example SWIG programs using the SNAP Ringo for multi-attribute edges are in the examples directory. The benchmark program benchmark.py performs a series of functions on the graph data, including node/edge iteration, degree checks, clustering coefficients, largest weakly and strongest components, etc. For R-MAT graphs with 1 million nodes and 10 million edges, this takes on average:

  • On CentOS 6.3 with 2.66 GHz processor, 19.71 sec to generate a new graph and and 17.49 sec to run the tests.
  • On Mac OSX 10.8 with 2.6 GHz processor, 13.95 sec to generate and 15.06 sec to run the tests.

To run a benchmark test you can run the following command:

python benchmark.py --verbose -n 5 --range 4-7 --type rmat --generate

snap-python's People

Contributors

albzheng avatar averyr2 avatar benpastel avatar cxhernandez avatar dkumazaw avatar farzaank avatar jihun-hong avatar karkumar avatar minghan avatar nnathur avatar nshelly avatar rcchen avatar roks avatar ruth-ann avatar smacke avatar sramas15 avatar visweshk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

snap-python's Issues

is snap suitable for large graphs REST microservices?

Hi All,

I have a question for my interest in building MVP, a platform to visualise large complex graphs.
I would like to inquire snap to reduce size of complex graphs, save costs respect to in-memory graph-database, and use graph-analytics in real time (e.g. community detections on selected sub-graphs and cosine similarity on selected nodes).

As a simple set up, I would only be operating Read and eventually Update operations, while insert may be created periodically at computing a new database.

My graphs are typically weighted graphs, so I would need to store attributes on edges (in some cases more than one numerical attribute).

To query a node, I will typically use hash-tables, mapping human readble ID (string) to graph id.

Could you sketch a few comments if storing graphs as binary objects is a good solution to meet above description?
Which size I may expect for these networks like 100M nodes and 10^9 relationships ?
Which machine requirements could need ?
Which advantages / disadvantages I may except ?

As a demo example, this is what I'd like to build for knowledge networks of academic interest:
http://nifty.works/about/4xJWNMLgg2aL16y9/dna#topic-article
http://genomics.nifty.works/insight/EFO_0000270/EFO_0003818/?intersection=0&limit&offset&skip_id#topic-article

Use more diverse exceptions than RuntimeError

I noticed almost all exceptions raised by this library are base RuntimeError exceptions.
It would be nice to use a bigger set of exceptions classes, so they can be more easily handled programmatically.

How can I use GetSAttrDat and G1.GetSAttrDatE?

Hi there,

I am trying to use GetSAttrDat and G1.GetSAttrDatE in my code, and I have found AddSAttrDatN and AddSAttrDatE working well, as below:

for NI in G1.Nodes():
    A = samples[:,NI.GetId()]
    count1 = [A[A==1]][0].shape[0]
    count_1 = [A[A==-1]][0].shape[0]
    p1 = count1/len(A)
    p_1 = count_1/len(A)
#     print p1,p_1
    G1.AddSAttrDatN(NI.GetId(), 'node_prob1', p1)
    G1.AddSAttrDatN(NI.GetId(), 'node_prob_1', p_1)

but I could not get below working

for NI in G1.Nodes():
    print G1.GetSAttrDatN(NI.GetId(), 'node_prob1', m)

Could anyone give more hint than manual on how to use these two functions ? Thanks!

'module' object has no attribute 'TRnd_LoadXml'

When I try to import snap, the following error occurs.

import snap
Traceback (most recent call last):
File "", line 1, in
File "/anaconda/lib/python2.7/site-packages/snap.py", line 7868, in
TRnd.LoadXml = new_instancemethod(_snap.TRnd_LoadXml,None,TRnd)
AttributeError: 'module' object has no attribute 'TRnd_LoadXml'

Use TypeError when the number of arguments mismatches the definition

TypeError is the exception class supposed to be used when a function call uses a wrong number of arguments. Example:

>>> def foo():
...  pass
... 
>>> foo(4)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: foo() takes no arguments (1 given)

However, this library uses NotImplementedError:

>>> import snap
>>> g = snap.PUNGraph.New()
>>> g.GetNI()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NotImplementedError: Wrong number or type of arguments for overloaded function 'PUNGraph_GetNI'.
  Possible C/C++ prototypes are:
    TUNGraph::GetNI(int const &) const
    TUNGraph::GetNI(int const &)

But NotImplementedError should be used only for abstract methods

ld: symbols not found when compiling on OS X Yosemite

The full error is as follows:

% make --INS--
make -C swig
g++ -lpython -dynamiclib -headerpad_max_install_names -o _snap.so snap_wrap.o Snap.o cliques.o agm.o agmfast.o agmfit.o
Undefined symbols for architecture x86_64:
"TDirNet::GetEI(int const&) const", referenced from:
_wrap_TDirNet_GetEI(object, object) in snap_wrap.o
(maybe you meant: _ZNK7TDirNet5GetEIERKiS1)
"TUndirNet::GetEI(int const&) const", referenced from:
_wrap_TUndirNet_GetEI(object, object) in snap_wrap.o
(maybe you meant: _ZNK9TUndirNet5GetEIERKiS1)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [_snap.so] Error 1
make: *** [swig] Error 2

thanks!

tneanet.py cannot import snap.py

Hi,

When I run make from /snap-python I get the following error :

'''
...
adv -I../../snap/glib-core
g++ -lpython -dynamiclib -o _snap.so snap_wrap.o Snap.o cliques.o
make -C test
python tneanet.py
Traceback (most recent call last):
File "tneanet.py", line 3, in
from snap import *
ImportError: No module named snap
make[1]: *** [tneanet] Error 1
make: *** [test] Error 2
'''

The problem appears to be that snap.py is not on the PYTHONPATH, at that point in the build process it has not been copied into "site-packages."

The simplest solution is to modify the make file for test to place ../swig on the path

Pull request to follow.

Several errors with DrawGViz

The function snap.DrawGViz behaves a little strangely. In particular:

  1. If the file extension to save to is not a supported format type, it throws a confusing error message:

Repro code:

import snap
G = snap.TUNGraph.New()
G.AddNode(1)
snap.DrawGViz(G, snap.gvlDot, 'error .png', 'Test', True)

Error:

Traceback (most recent call last):
  File "error-repro.py", line 4, in <module>
    snap.DrawGViz(G, snap.gvlDot, 'data/G', 'Test', True)
  File "/Users/mo/StefanoWork/lib/python2.7/site-packages/snap.py", line 250999, in DrawGViz
    if type(tspec) == PUNGraph: return DrawGViz_PUNGraph(tspec, *args)
  File "/Users/mo/StefanoWork/lib/python2.7/site-packages/snap.py", line 239823, in DrawGViz_PUNGraph
    return _snap.DrawGViz_PUNGraph(*args)
RuntimeError: Execution stopped: Ext==".ps" || Ext==".gif" || Ext==".png", file ../../snap/snap-core/gviz.cpp, line 13

The above error should be handled gracefully and throw a better error message :)

  1. Some characters in the passed filename are not escaped correctly; for example, if the filename has a space in it, snap throws an error:

repro code:

import snap
G = snap.TUNGraph.New()
G.AddNode(1)
snap.DrawGViz(G, snap.gvlDot, 'error .png', 'Test', True)

Error:

Error: dot: can't open error
Error: dot: can't open 2.dot
Error: dot: can't open 2.png
sh: ./dot: No such file or directory
sh: /usr/bin/dot: No such file or directory
[../../snap/snap-core/gviz.cpp:24] Cannot find GraphViz (dot -Tpng error 2.dot -o error 2.png). Set the PATH.

Off-by-one error in GetMxNId()

The documentation for GetMxNId() says: Returns the maximum ID of a any node in the graph. However, it is consistently off by 1 (too high). To repro:

import snap

G = snap.TUNGraph.New()
G.AddNode(1)
G.AddNode(2)
G.AddEdge(1,2)
print G.GetMxNId() # Prints 3

Import Error with Snap.py

I receive the following error on "import snap"

OS X 10.9.4
Python Version: 3.4

/.../lib/python3.4/imp.py in load_module(name, file, filename, details)
241 return load_dynamic(name, filename, opened_file)
242 else:
--> 243 return load_dynamic(name, filename, file)
244 elif type_ == PKG_DIRECTORY:
245 return load_package(name, filename)

ImportError: dynamic module does not define init function (PyInit__snap)

Access areas for PTO and PWM

The documentation states that special memory bytes eg SM66.4 for PTO/PWM control.
I checked the source code but could not find special memory bytes in the Areas constants.
Any help to access these?

'module' object has no attribute 'TRnd'

When I try to import snap, the following error occurs.


AttributeError                            Traceback (most recent call last)
<ipython-input-1-043aa781ac7d> in <module>()
      1 import snap
----> 2 Rnd = snap.TRnd(1,0)
      3 UGraph= snap.GenSmallWorld(N,k,p,Rnd)
      4 snap.DrawGViz(UGraph,snap.gvlCirco,"WS.png","WS small world",False)
      5 GraphClustcoeff = snap.GetClustCf(UGraph,-1)

AttributeError: 'module' object has no attribute 'TRnd'

Semantics of Nodes() vs GetNodes()

Nodes() currently returns a generator function that iterates across all the nodes in a graph, while GetNodes() returns the number of nodes in the graph. The latter is easily confused with the former, especially when one is just starting out with Snap.py. I would like to propose renaming the latter function to NumNodes().

The same issue exists with Edges() and GetEdges()

GetPageRank() got an unexpected keyword argument 'C'

In the documentations it's mentioned that GetPageRank accepts 3 keyword arguments, C, Eps and MaxIter but when i call it in my code like this for instance

...
g = snap.GenRndGnm(snap.PNGraph, 100, 1000)
PRankH = snap.TIntFltH()
snap.GetPageRank(g, PRankH, C=0.8, Eps=10e-8, MaxItr=100)

I get an error as:
Traceback (most recent call last):
File "", line 1, in
TypeError: GetPageRank() got an unexpected keyword argument 'C'

a bug in the documentations maybe.
regards.

snap-python make fails with error

I am getting this error after running make command.

$ cd snap-python/
$ ls
Makefile README.md doc setup test
Makefile.config dev examples swig
$ make
make -C swig
make[1]: Nothing to be done for `all'.
make -C test
python tneanet.py
Traceback (most recent call last):
File "tneanet.py", line 3, in
from snap import *
ImportError: No module named snap
make[1]: *** [tneanet] Error 1
make: *** [test] Error 2

how to query a node by attribute?

I have a multimode graph, and would like to add string attributes to nodes (such as type and _id, where _id a string) and query by the "human readable" _id:

I tried:
g.AddNode(0)

g.AddSAttrDatN(0, 'Disease', 'EFO_0000270')

but then I cannot find which method (if exist) returns you the node by querying 'EFO_0000270'.

Any help?

global name 'PNEANetMP' is not defined

the code is :

nap.DrawGViz(UGraph,snap.gvlCirco,"WS.png","WS small world",False)

and the results shows:

NameError Traceback (most recent call last)
in ()
----> 1 snap.DrawGViz(UGraph,snap.gvlCirco,"WS.png","WS small world",False)

C:\Users\julia\Anaconda2\lib\site-packages\snap.pyc in DrawGViz(tspec, *args)
208718 if type(tspec) == PNGraph : return DrawGViz_PNGraph(tspec, *args)
208719 if type(tspec) == PNEANet : return DrawGViz_PNEANet(tspec, *args)
---->208720 if type(tspec) == PNEANetMP : return DrawGViz_PNEANetMP(tspec, *args)
208721 if type(tspec) == PNGraphMP: return DrawGViz_PNGraphMP(tspec, *args)
208722 raise TypeError('First argument has invalid type')

NameError: global name 'PNEANetMP' is not defined

I don't know if there is any problem in the setup files. Pls help. Thx a lot.

name 'snap' is not defined

When I draw the UGraph network by the open source tool called DrawGViz in the layout of glvCirco:
snap.DrawGViz(UGraph,snap.gvlCirco,"WS.png","WS small world",False)

The results shows:


NameError Traceback (most recent call last)
in ()
----> 1 snap.DrawGViz(UGraph,snap.gvlCirco,"WS.png","WS small world",False)

NameError: name 'snap' is not defined

Pls help. Thx.

Python 3 support

Is there any effort at the moment for supporting Python 3? What would be required for adding Python 3 support, would it be possible to create a cython, cffi , xdress wrapper instead of using swig?

snap.GenRMat is not a thing in my installation of snap on Mac OS?

On a Mac OS system I try to use snap.GenRMat and I get an error. I did do brew install swig and even with that package/module installed I get the error (see below). Clearly I must be doing something wrong since I don't see evidence that others are having the same issue. What should I do?

>>> import snap
>>> P = [[.9124,.5884],[.5029,.2165]]
>>> sum = .9124+.5884+.5029+.2165 #enron
>>> num_nodes=6; num_edges=8
>>> GRmatSNAP = snap.GenRMat(num_nodes, num_edges, P[0][0]/sum, P[0][1]/sum, P[1][0]/sum)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'GenRMat'

Unable to Generate Power Law Graph with ConfModel = False

I am trying to generate a Power Law Graph using the the command-
Graph1 = snap.GenRndPowerLaw(Nodes, PowerExp, False)
The given code works with Nodes = 5 and any PowerExp > 1 but fails if Nodes > 5
Attached is the output for both the cases-
Graph1 = snap.GenRndPowerLaw(5, 2, False)
5 nodes, 5 edges
Randomizing edges (5, 3)...
total 0k switchings attempted, 0k skiped [0.00s]

Graph1 = snap.GenRndPowerLaw(6, 2, False)
6 nodes, 9 edges
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "snap.py", line 35776, in GenRndPowerLaw
return _snap.GenRndPowerLaw(*args)
RuntimeError: Execution stopped: DegSeqV.IsSorted(false) [Reason:'DegSeqV must be sorted in descending order.'], file ../../snap/snap-core/ggen.cpp, line 65

Cannot compile: “error: ‘typedef class TPt<TStrPool> TStrHash<TInt>::PStringPool’ is private”

 progval@ion  ~/src/snap-python   master  make
make -C swig
make[1]: Entering directory '/home/progval/src/snap-python/swig'
swig -D_CMPWARN -D__stdcall -DSW_SNAPPY -python -c++ -w302,312,317,325,362,383,384,389,401,503,508,509 -O -I../../snap/snap-core -I../../snap/snap-adv -I../../snap/glib-core snap.i
g++ -std=c++98 -Wall -O3 -DNDEBUG -fPIC -D__STDC_LIMIT_MACROS -DSW_SNAPPY -fopenmp -c snap_wrap.cxx -I../../snap/snap-core -I../../snap/snap-adv -I../../snap/glib-core  -I/usr/include/python2.6 -I/usr/include/python2.7
In file included from ../../snap/glib-core/base.h:163:0,
                 from ../../snap/snap-core/Snap.h:8,
                 from snap_wrap.cxx:3554:
../../snap/glib-core/hash.h: In function ‘PyObject* _wrap_new_TStrIntSH__SWIG_1(PyObject*, int, PyObject**)’:
../../snap/glib-core/hash.h:719:28: error: ‘typedef class TPt<TStrPool> TStrHash<TInt>::PStringPool’ is private
   typedef TPt<TStringPool> PStringPool;
                            ^
snap_wrap.cxx:156046:55: error: within this context
   TStrHash< TInt,TStrPool,TDefaultHashFunc< TStr > >::PStringPool *arg1 = 0 ;
                                                       ^
In file included from ../../snap/glib-core/base.h:163:0,
                 from ../../snap/snap-core/Snap.h:8,
                 from snap_wrap.cxx:3554:
../../snap/glib-core/hash.h:719:28: error: ‘typedef class TPt<TStrPool> TStrHash<TInt>::PStringPool’ is private
   typedef TPt<TStringPool> PStringPool;
                            ^
snap_wrap.cxx:156059:80: error: within this context
   arg1 = reinterpret_cast< TStrHash< TInt,TStrPool,TDefaultHashFunc< TStr > >::PStringPool * >(argp1);
                                                                                ^
In file included from ../../snap/glib-core/base.h:163:0,
                 from ../../snap/snap-core/Snap.h:8,
                 from snap_wrap.cxx:3554:
../../snap/glib-core/hash.h:719:28: error: ‘typedef class TPt<TStrPool> TStrHash<TInt>::PStringPool’ is private
   typedef TPt<TStringPool> PStringPool;
                            ^
snap_wrap.cxx:156062:178: error: within this context
       result = (TStrHash< TInt,TStrPool,TDefaultHashFunc< TStr > > *)new TStrHash< TInt,TStrPool,TDefaultHashFunc< TStr > >((TStrHash< TInt,TStrPool,TDefaultHashFunc< TStr > >::PStringPool const &)*arg1);
                                                                                                                                                                                  ^
In file included from ../../snap/glib-core/base.h:163:0,
                 from ../../snap/snap-core/Snap.h:8,
                 from snap_wrap.cxx:3554:
../../snap/glib-core/hash.h: In function ‘PyObject* _wrap_new_TStrIntSH__SWIG_2(PyObject*, int, PyObject**)’:
../../snap/glib-core/hash.h:719:28: error: ‘typedef class TPt<TStrPool> TStrHash<TInt>::PStringPool’ is private
   typedef TPt<TStringPool> PStringPool;
                            ^
snap_wrap.cxx:156078:55: error: within this context
   TStrHash< TInt,TStrPool,TDefaultHashFunc< TStr > >::PStringPool *arg3 = 0 ;
                                                       ^
In file included from ../../snap/glib-core/base.h:163:0,
                 from ../../snap/snap-core/Snap.h:8,
                 from snap_wrap.cxx:3554:
../../snap/glib-core/hash.h:719:28: error: ‘typedef class TPt<TStrPool> TStrHash<TInt>::PStringPool’ is private
   typedef TPt<TStringPool> PStringPool;
                            ^
snap_wrap.cxx:156109:80: error: within this context
   arg3 = reinterpret_cast< TStrHash< TInt,TStrPool,TDefaultHashFunc< TStr > >::PStringPool * >(argp3);
                                                                                ^
In file included from ../../snap/glib-core/base.h:163:0,
                 from ../../snap/snap-core/Snap.h:8,
                 from snap_wrap.cxx:3554:
../../snap/glib-core/hash.h:719:28: error: ‘typedef class TPt<TStrPool> TStrHash<TInt>::PStringPool’ is private
   typedef TPt<TStringPool> PStringPool;
                            ^
snap_wrap.cxx:156112:217: error: within this context
       result = (TStrHash< TInt,TStrPool,TDefaultHashFunc< TStr > > *)new TStrHash< TInt,TStrPool,TDefaultHashFunc< TStr > >((int const &)*arg1,(bool const &)*arg2,(TStrHash< TInt,TStrPool,TDefaultHashFunc< TStr > >::PStringPool const &)*arg3);
                                                                                                                                                                                                                         ^
In file included from ../../snap/glib-core/base.h:163:0,
                 from ../../snap/snap-core/Snap.h:8,
                 from snap_wrap.cxx:3554:
../../snap/glib-core/hash.h: In function ‘PyObject* _wrap_TStrIntSH_SetPool(PyObject*, PyObject*)’:
../../snap/glib-core/hash.h:719:28: error: ‘typedef class TPt<TStrPool> TStrHash<TInt>::PStringPool’ is private
   typedef TPt<TStringPool> PStringPool;
                            ^
snap_wrap.cxx:156581:55: error: within this context
   TStrHash< TInt,TStrPool,TDefaultHashFunc< TStr > >::PStringPool *arg2 = 0 ;
                                                       ^
In file included from ../../snap/glib-core/base.h:163:0,
                 from ../../snap/snap-core/Snap.h:8,
                 from snap_wrap.cxx:3554:
../../snap/glib-core/hash.h:719:28: error: ‘typedef class TPt<TStrPool> TStrHash<TInt>::PStringPool’ is private
   typedef TPt<TStringPool> PStringPool;
                            ^
snap_wrap.cxx:156601:80: error: within this context
   arg2 = reinterpret_cast< TStrHash< TInt,TStrPool,TDefaultHashFunc< TStr > >::PStringPool * >(argp2);
                                                                                ^
In file included from ../../snap/glib-core/base.h:163:0,
                 from ../../snap/snap-core/Snap.h:8,
                 from snap_wrap.cxx:3554:
../../snap/glib-core/hash.h:719:28: error: ‘typedef class TPt<TStrPool> TStrHash<TInt>::PStringPool’ is private
   typedef TPt<TStringPool> PStringPool;
                            ^
snap_wrap.cxx:156604:76: error: within this context
       (arg1)->SetPool((TStrHash< TInt,TStrPool,TDefaultHashFunc< TStr > >::PStringPool const &)*arg2);
                                                                            ^
In file included from ../../snap/glib-core/base.h:163:0,
                 from ../../snap/snap-core/Snap.h:8,
                 from snap_wrap.cxx:3554:
../../snap/glib-core/hash.h: In function ‘PyObject* _wrap_TStrIntSH_GetPool(PyObject*, PyObject*)’:
../../snap/glib-core/hash.h:719:28: error: ‘typedef class TPt<TStrPool> TStrHash<TInt>::PStringPool’ is private
   typedef TPt<TStringPool> PStringPool;
                            ^
snap_wrap.cxx:156638:91: error: within this context
   resultobj = SWIG_NewPointerObj((new TStrHash< TInt,TStrPool,TDefaultHashFunc< TStr > >::PStringPool(static_cast< const TStrHash< TInt,TStrPool,TDefaultHashFunc< TStr > >::PStringPool& >(result))), SWIGTYPE_p_TPtT_TStrPool_t, SWIG_POINTER_OWN |  0 );
                                                                                           ^
snap_wrap.cxx:1172:89: note: in definition of macro ‘SWIG_NewPointerObj’
 #define SWIG_NewPointerObj(ptr, type, flags)            SWIG_Python_NewPointerObj(NULL, ptr, type, flags)
                                                                                         ^
In file included from ../../snap/glib-core/base.h:163:0,
                 from ../../snap/snap-core/Snap.h:8,
                 from snap_wrap.cxx:3554:
../../snap/glib-core/hash.h:719:28: error: ‘typedef class TPt<TStrPool> TStrHash<TInt>::PStringPool’ is private
   typedef TPt<TStringPool> PStringPool;
                            ^
snap_wrap.cxx:156638:174: error: within this context
   resultobj = SWIG_NewPointerObj((new TStrHash< TInt,TStrPool,TDefaultHashFunc< TStr > >::PStringPool(static_cast< const TStrHash< TInt,TStrPool,TDefaultHashFunc< TStr > >::PStringPool& >(result))), SWIGTYPE_p_TPtT_TStrPool_t, SWIG_POINTER_OWN |  0 );
                                                                                                                                                                              ^
snap_wrap.cxx:1172:89: note: in definition of macro ‘SWIG_NewPointerObj’
 #define SWIG_NewPointerObj(ptr, type, flags)            SWIG_Python_NewPointerObj(NULL, ptr, type, flags)
                                                                                         ^
Makefile:38: recipe for target 'snap_wrap.o' failed
make[1]: *** [snap_wrap.o] Error 1
make[1]: Leaving directory '/home/progval/src/snap-python/swig'
Makefile:14: recipe for target 'swig' failed
make: *** [swig] Error 2

System: Debian Jessie, with libglib2.0-dev version 2.42.1-1 and g++ 4.9.2-10

GetFltAttrDatN returns string attributes and vice-versa.

Hello, I believe this behavior is weird, and possibly a bug.
Consider the following code:

>>> import snap
>>> network = snap.TNEANet()
>>> network.AddNode(1) 
1
>>> network.AddFltAttrDatN(1, 22.5, "float_attr")
0
>>> network.AddStrAttrDatN(1, "hi there", "str_attr")
0
>>> network.GetFltAttrDatN(1, "float_attr")  # we find the float attribute, ok!
22.5
>>> network.GetFltAttrDatN(1, "str_attr") # wait...what? There is no float attribute called "str_attr"
22.5

# the same thing happens if we search for "float_attr" in the string attributes:
>>> network.GetStrAttrDatN(1, "str_attr") # looks good
'hi there'
>>> network.GetStrAttrDatN(1, "float_attr") # huh?
'hi there'

>>> network.GetFltAttrDatN(1, "random_string")  # if we search for something that does not exist we get an error, that is fine...
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
RuntimeError: Execution stopped: (0<=ValN)&&(ValN<Vals) [Reason:'Index:-1 Vals:2 MxVals:16 Type:4TVecI11THashKeyDatI4TStr5TPairI4TIntS3_EEiE'], file ../../snap/glib-core/ds.h, line 459

GetClosenessCentr Malfunction

I have been reviewing the documentation here and of the three examples on that page, the only one I can get to work with Python2.7 is the second one. Unfortunately, I need this method to work on a directed graph... Is anyone else seeing this same problem?

Neither SaveEdgeList nor DrawGViz support saving in directories other than current one

The following code

import snap

G = snap.TUNGraph.New()
G.AddNode(1)
G.AddNode(2)
G.AddEdge(1,2)
snap.SaveEdgeList(G, "data/G.txt", "Save as tab-separated list of edges")

results in segmentation fault on macOS. Also a segfault if the last line is replaced with snap.DrawGViz(G, snap.gvlDot, 'data/G.txt', 'Test', True) . The segmentation fault occurs whenever saving in a directory other than the current one.

Overload __repr__

At least TUNGraph and TUNGraphNodeI have no custom representation, so the default Python one is used.
But this representation does not show informations about the object; so having a better one would be nice.
For instance, repr(graph) could show a list of nodes and edges if the graph is not too big; and a summary otherwise.

Snap-py won't build against Anaconda OSX

The linker appears to be linking against the wrong set of dynamic libraries when building against Python 2.7.6 :: Anaconda 1.9.1 :: OSX 10.9.2

The following error appears:

env PYTHONPATH=../swig python tneanet.py 
Fatal Python error: PyThreadState_Get: no current thread
make[1]: *** [tneanet] Abort trap: 6
make: *** [test] Error 2

The problem seems to be that _snap.so is being linked to the system python library instead of the anaconda version. When you run ../snap-python/otool -L _snap.so you get :

otool -L _snap.so 
_snap.so:
    _snap.so (compatibility version 0.0.0, current version 0.0.0)
    /System/Library/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.5)
    /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)

You can fix the error by running

install_name_tool -change /System/Library/Frameworks/Python.framework/Versions/2.7/Python /[PATH TO ANACONDA]/anaconda/lib/libpython2.7.dylib

Exception raised by snap.TUNGraphNodeI's methods are unhelpful

>>> import snap
>>> g = snap.TUNGraph.New()
>>> g.AddNode(1)
1
>>> n = list(g.Nodes())[0]
>>> n
<snap.TUNGraphNodeI; proxy of <Swig Object of type 'TUNGraphNodeI *' at 0x7f9dd9515810> >
>>> n.GetId()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
RuntimeError: Execution stopped: (KeyDatI!=NULL)&&(KeyDatI->HashCd!=-1), file ../../snap/glib-core/hash.h, line 72

Missing Python 3 support

Python 3 is currently not supported. Even after fixing setup.py, I get this when trying to import snap:

ImportError: dynamic module does not define init function (PyInit__snap)

Weighted graphs

Hi, sorry, if this is a basic question.
Is there any way to have weighted graphs in snap-py?

undefined symbol error when trying to load snap on either centos-7 or Ubuntu 15.04

After making snap-python, I get this error:

import sys;sys.path.append('swig')
import snap
Traceback (most recent call last):
File "", line 1, in
File "swig/snap.py", line 30, in
_snap = swig_import_helper()
File "swig/snap.py", line 26, in swig_import_helper
_mod = imp.load_module('_snap', fp, pathname, description)
ImportError: swig/_snap.so: undefined symbol: _ZNK7TDirNet5GetEIERKi

Snap crashes IPython on OSX 10.9.5 Anaconda Install

Hi,

I'm trying to use Snap with IPython on OSX 10.9.5 with Anaconda Python v. 3.8.1. However, I keep getting a fatal crash.

(gl)Andrews-MacBook-Pro:~ ag$ ipython qtconsole --pylab=inline
QPixmap::scaled: Pixmap is a null pixmap
Fatal Python error: PyThreadState_Get: no current thread

Snap imports correctly in IPython when not using qtconsole.

Do you have any advice?

Thanks,
Andrew

Download links in README

These should be corrected to the https links to avoid permissions errors on some machines.

 git clone [email protected]:snap-stanford/snap-python.git
 git clone [email protected]:snap-stanford/snap.git
git clone https://github.com/snap-stanford/snap-python.git
git clone https://github.com/snap-stanford/snap.git

AddFltAttrN updates all of nodes' float attrbiutes

Hi,

The following bug is present in the Snap.py library.
All of nodes' float attributes get overridden when you set its attribute with AddFltAttrN.

The problem exists only for float attributes. Nodes with multiple string or integer attributes work fine.

Example:

import snap
G = snap.GenFull(snap.PNEANet, 1)
G.AddFltAttrN("NValFlt", 0.0)
G.AddFltAttrN("NValFlt2", 0.0)
G.AddFltAttrN("NValFlt3", 0.0)
nid = G.GetNI(0).GetId()
G.AddFltAttrDatN(nid, float(1), "NValFlt")
G.AddFltAttrDatN(nid, float(5), "NValFlt2")
G.AddFltAttrDatN(nid, float(10), "NValFlt3")
fval = G.GetFltAttrDatN(nid, "NValFlt")
fval2 = G.GetFltAttrDatN(nid,  "NValFlt2")
fval3 = G.GetFltAttrDatN(nid,  "NValFlt3")
print fval, fval2, fval3 # prints 10.0, 10.0, 10.0 instead of 1.0, 5.0, 10.0

Peter.

error in examples for snap-python/doc/source/reference/DrawGViz1.rst

For an undirected graph which has only 10 nodes, it can has at most 45 edges.
But in your example, you give 50 edges to the GenRndGnm method, then it crashed on my machine.

UGraph = snap.GenRndGnm(snap.PUNGraph, 10, ~~50~~)

I think you had better change it to 45 or any value below it.

TNEANet.StrAttrValueEI() Returns a vector of empty values

On Linux Debian 4.6.3-14, python 2.7.9

  1. Create a new *_TNEANet *_graph
  2. Created two nodes with IDs 0,1
  3. Created an edge between between 0,1 with ID 2
  4. Added a string attribute to node 0.
  5. Added a string attribute to node 1.
  6. Added two string attributes to edge (which has ID=2)
    6.** StrAttrNameNI()**, StrAttrValueNI() works well on both nodes.
  7. On edge: StrAttrNameEI() returns the correct names but G.StrAttrValueEI() returns empty string.

Sample code is attached below:
`from snap import *

STRS = {"0":"000", "1":"111", "2":"222", "3":"333"}

def get_str(k):
return TStr(STRS[k])

G = TNEANet.New()
G.AddNode(0)
G.AddNode(1)
G.AddEdge(0, 1, 2)

G.AddStrAttrDatN(0, STRS['0'], "ATTR")
G.AddStrAttrDatN(1, STRS['1'], "ATTR")

G.AddStrAttrDatE(2, STRS['2'], "ATTR1")
G.AddStrAttrDatE(2, STRS['3'], "ATTR2")
G.Dump()
print "---------------------------------------------------------\n\n"

Works well for Node 0

NAMES = TStrV()
VALS = TStrV()
G.StrAttrNameNI(0, NAMES)
G.StrAttrValueNI(0, VALS)
print "FOR NODES 0: NAME[0]: %s, VAL[0]: %s" % (NAMES[0], VALS[0])

Works well for Node 1

NAMES = TStrV()
VALS = TStrV()
G.StrAttrNameNI(1, NAMES)
G.StrAttrValueNI(1, VALS)
print "FOR NODES 1: NAME[0]: %s, VAL[0]: %s" % (NAMES[0], VALS[0])

For Edge 2: Returns only the names.

NAMES = TStrV()
VALS = TStrV()
G.StrAttrNameEI(2, NAMES)
G.StrAttrValueEI(2, VALS)
print "FOR EDGE: NAME[0,1]: %s,%s, VAL[0,1]: %s,%s" % (NAMES[0], NAMES[1], VALS[0], VALS[1])

`

[Functionality request] Graph embedding

Hello,

It would be nice if SNAP has graph embedding algorithm such as DeepWalk (B. Perozzi et al.) or LINE (Jian Tang et al.). Is there anyone interested in this field? Currently I am studying NLP techniques that can be applied for networks to discover latent representations, and I think it can be helpful to implement some embedding algorithms for the SNAP framework.

TNEANet.Nodes() method does not exist in Snap.py

Hello, I am using Snap.py version 1.2
I have not seen this issue anywhere else on Github, but I did find it in the Google groups. So I decided to open an issue here as well.

Contrary to what the manual states, TNEANet does not have the Nodes() method. It will fail if called and using dir does not show the method at all, so something does seem wrong...

Make failing due to no matching `is_nan` function

I have cloned the snap-python and snap repos and confirmed that swig is installed. When I cd to the snap-python directory and run make, it fails with the following error:

In file included from ../../snap/snap-core/Snap.cpp:8:
../../snap/glib-core/linalg.cpp:708:32: error: no matching function for call to 'isnan'
                        Assert(_isnan(a(j-1,k-1)) == 0);
                               ^~~~~~~~~~~~~~~~~~
../../snap/glib-core/bd.h:46:19: note: expanded from macro '_isnan'
#define _isnan(x) isnan(x)
                  ^~~~~
../../snap/glib-core/bd.h:252:5: note: expanded from macro 'Assert'
  ((Cond) ? static_cast<void>(0) : ExeStop(NULL, NULL, #Cond, __FILE__, __LINE__))
    ^~~~
/Library/Developer/CommandLineTools/usr/include/c++/v1/math.h:464:25: note: candidate template ignored: disabled by 'enable_if' [with _A1 = TFlt]
typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
                        ^
/Library/Developer/CommandLineTools/usr/include/c++/v1/math.h:472:25: note: candidate template ignored: disabled by 'enable_if' [with _A1 = TFlt]
typename std::enable_if<std::is_integral<_A1>::value, bool>::type

Within math.h is the following code:

// isnan

#ifdef isnan

template <class _A1>
_LIBCPP_ALWAYS_INLINE
bool
__libcpp_isnan(_A1 __lcpp_x) _NOEXCEPT
{
    return isnan(__lcpp_x);
}

#undef isnan

template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY
typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
isnan(_A1 __lcpp_x) _NOEXCEPT
{
    return __libcpp_isnan((typename std::__promote<_A1>::type)__lcpp_x);
}

template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY
typename std::enable_if<std::is_integral<_A1>::value, bool>::type
isnan(_A1) _NOEXCEPT
{ return false; }

#endif  // isnan

I also get an error with isnan when specifying make CC=gcc-7:

../../snap/glib-core/bd.h:46:26: error: no matching function for call to 'isnan(TFlt&)'
 #define _isnan(x) isnan(x)
                          ^
../../snap/glib-core/bd.h:252:5: note: in definition of macro 'Assert'
   ((Cond) ? static_cast<void>(0) : ExeStop(NULL, NULL, #Cond, __FILE__, __LINE__))
     ^~~~
../../snap/glib-core/linalg.cpp:708:32: note: in expansion of macro '_isnan'
                         Assert(_isnan(a(j-1,k-1)) == 0);
                                ^~~~~~
In file included from /usr/local/Cellar/gcc/7.3.0_1/include/c++/7.3.0/math.h:36:0,
                 from ../../snap/glib-core/base.h:132,
                 from ../../snap/snap-core/Snap.h:9,
                 from ../../snap/snap-core/Snap.cpp:4:
/usr/local/Cellar/gcc/7.3.0_1/include/c++/7.3.0/cmath:877:5: note: candidate: template<class _Tp> typename __gnu_cxx::__enable_if<std::__is_arithmetic<_Tp>::__value, int>::__type std::isnan(_Tp)
     isnan(_Tp __f)
     ^~~~~
/usr/local/Cellar/gcc/7.3.0_1/include/c++/7.3.0/cmath:877:5: note:   template argument deduction/substitution failed:
/usr/local/Cellar/gcc/7.3.0_1/include/c++/7.3.0/cmath: In substitution of 'template<class _Tp> typename __gnu_cxx::__enable_if<std::__is_arithmetic<_Tp>::__value, int>::__type std::isnan(_Tp) [with _Tp = TFlt]':
../../snap/glib-core/linalg.cpp:708:25:   required from here
/usr/local/Cellar/gcc/7.3.0_1/include/c++/7.3.0/cmath:877:5: error: no type named '__type' in 'struct __gnu_cxx::__enable_if<false, int>'
In file included from ../../snap/glib-core/base.h:178:0,
                 from ../../snap/snap-core/Snap.h:9,
                 from ../../snap/snap-core/Snap.cpp:4:

which has the following math.h:

  template<typename _Tp>
    inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
                                           int>::__type
    isnan(_Tp __f)
    {
      typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
      return __builtin_isnan(__type(__f));
    }

I guess it may be a compiler issue on my end since no one is experiencing this problem with isnan with the TFlt type during make, but I still can't figure out exactly what it is.

'module' object has no attribute 'trnd'

When I try to import snap, the following issue occurs.
1 import snap
----> 2 Rnd = snap.trnd()
3 UGraph = snap.GenPrefAttach(500,1,Rnd)
4 snap.DrawGViz(UGraph,snap.gvlSfdp,"graph_generation_exp.png","BA network",False)
5 snap.PlotInDegDistr(UGraph,"Degree_distribution","Degree distribution(BA network)")

AttributeError: 'module' object has no attribute 'trnd'

Error running benchmark

Python 2.7.3
Debian 7.6

I have installed swig, gnuplot and graphviz from Debian repos.

I cloned both repos:

git clone https://github.com/snap-stanford/snap-python
git clone https://github.com/snap-stanford/snap

I did make, I got some warrnings, but no errors.

I can import snap from python interpreter.

But when I try to run benchmark, it fails with the error below. Any clue how to fix this?

$ python benchmark.py -v -g -r 4-6
Edge degree = 10^1 to 10^2 edges/node
Hostname: pablo-E5530
Node range = 10^4 to 10^6
Running results from 4.000000e+00 to 6.000000e+00
Iteration: 1 of 1
Non-deterministic mode
Using average degree of 10^1
Generating 'attribute rand_neanet' graph with 1.000000e+04 nodes, 1.000000e+05 edges... 1 10000 100000
2
3 10000 100000
done
Running tests...
Traceback (most recent call last):
File "benchmark.py", line 435, in
main()
File "benchmark.py", line 432, in main
run_tests(num_iterations, min, max)
File "benchmark.py", line 336, in run_tests
results = benchmark_neanet(Graph)
File "benchmark.py", line 160, in benchmark_neanet
results['max_scc_percent'] = snap.GetMxSccSz(Graph).GetNodes()
AttributeError: 'float' object has no attribute 'GetNodes'

Build log:

pablo@pablo-E5530:~/Dev/Snap/snap-python$ make
make -C swig
make[1]: Entering directory `/home/pablo/SD64/Dev/Snap/snap-python/swig'
swig -D_CMPWARN -D__stdcall -DSW_SNAPPY -python -c++ -w302,312,317,325,362,383,384,389,401,503,508,509 -O -I../../snap/snap-core -I../../snap/snap-adv -I../../snap/glib-core snap.i
g++ -std=c++98 -Wall -O3 -DNDEBUG -fPIC -D__STDC_LIMIT_MACROS -DSW_SNAPPY -fopenmp -c snap_wrap.cxx -I../../snap/snap-core -I../../snap/snap-adv -I../../snap/glib-core  -I/usr/include/python2.6 -I/usr/include/python2.7
snap_wrap.cxx: In function ‘PyObject* _wrap_TIntHSI_Mn_get(PyObject*, PyObject*)’:
snap_wrap.cxx:738564:25: warning: variable ‘arg1’ set but not used [-Wunused-but-set-variable]
snap_wrap.cxx: In function ‘PyObject* _wrap_TIntHSI_Mx_get(PyObject*, PyObject*)’:
snap_wrap.cxx:738587:25: warning: variable ‘arg1’ set but not used [-Wunused-but-set-variable]
snap_wrap.cxx: In function ‘PyObject* _wrap_TIntHSI_Kilo_get(PyObject*, PyObject*)’:
snap_wrap.cxx:738610:25: warning: variable ‘arg1’ set but not used [-Wunused-but-set-variable]
snap_wrap.cxx: In function ‘PyObject* _wrap_TIntHSI_Mega_get(PyObject*, PyObject*)’:
snap_wrap.cxx:738633:25: warning: variable ‘arg1’ set but not used [-Wunused-but-set-variable]
snap_wrap.cxx: In function ‘PyObject* _wrap_TIntHSI_Giga_get(PyObject*, PyObject*)’:
snap_wrap.cxx:738656:25: warning: variable ‘arg1’ set but not used [-Wunused-but-set-variable]
snap_wrap.cxx: In function ‘PyObject* _wrap_TIntHSI_Rnd_get(PyObject*, PyObject*)’:
snap_wrap.cxx:738679:25: warning: variable ‘arg1’ set but not used [-Wunused-but-set-variable]
In file included from ../../snap/glib-core/base.h:161:0,
                 from ../../snap/snap-core/Snap.h:8,
                 from snap_wrap.cxx:3827:
../../snap/glib-core/ds.h: In instantiation of ‘int TVecPool<TVal, TSizeTy>::AddV(const TValV&) [with TVal = TInt; TSizeTy = int; TVecPool<TVal, TSizeTy>::TValV = TVec<TInt, int>]’:
snap_wrap.cxx:531102:72:   required from here
../../snap/glib-core/ds.h:2632:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
../../snap/glib-core/ds.h:2634:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
In file included from ../../snap/snap-core/Snap.h:36:0,
                 from snap_wrap.cxx:3827:
../../snap/snap-core/ggen.h: In instantiation of ‘PGraph TSnap::GenBaraHierar(const int&, const bool&) [with PGraph = TPt<TNEANet>]’:
snap_wrap.cxx:757198:112:   required from here
../../snap/snap-core/ggen.h:203:37: warning: variable ‘NI’ set but not used [-Wunused-but-set-variable]
../../snap/snap-core/ggen.h: In instantiation of ‘PGraph TSnap::GenBaraHierar(const int&, const bool&) [with PGraph = TPt<TNGraph>]’:
snap_wrap.cxx:770795:112:   required from here
../../snap/snap-core/ggen.h:203:37: warning: variable ‘NI’ set but not used [-Wunused-but-set-variable]
../../snap/snap-core/ggen.h: In instantiation of ‘PGraph TSnap::GenBaraHierar(const int&, const bool&) [with PGraph = TPt<TUNGraph>]’:
snap_wrap.cxx:784057:113:   required from here
../../snap/snap-core/ggen.h:203:37: warning: variable ‘NI’ set but not used [-Wunused-but-set-variable]
g++ -std=c++98 -Wall -O3 -DNDEBUG -fPIC -D__STDC_LIMIT_MACROS -DSW_SNAPPY -fopenmp -c ../../snap/snap-core/Snap.cpp -I../../snap/snap-core -I../../snap/snap-adv -I../../snap/glib-core
g++ -std=c++98 -Wall -O3 -DNDEBUG -fPIC -D__STDC_LIMIT_MACROS -DSW_SNAPPY -fopenmp -c ../../snap/snap-adv/cliques.cpp -I../../snap/snap-core -I../../snap/snap-adv -I../../snap/glib-core
g++ -std=c++98 -Wall -O3 -DNDEBUG -fPIC -D__STDC_LIMIT_MACROS -DSW_SNAPPY -fopenmp -c ../../snap/snap-adv/agm.cpp -I../../snap/snap-core -I../../snap/snap-adv -I../../snap/glib-core
g++ -std=c++98 -Wall -O3 -DNDEBUG -fPIC -D__STDC_LIMIT_MACROS -DSW_SNAPPY -fopenmp -c ../../snap/snap-adv/agmfast.cpp -I../../snap/snap-core -I../../snap/snap-adv -I../../snap/glib-core
g++ -std=c++98 -Wall -O3 -DNDEBUG -fPIC -D__STDC_LIMIT_MACROS -DSW_SNAPPY -fopenmp -c ../../snap/snap-adv/agmfit.cpp -I../../snap/snap-core -I../../snap/snap-adv -I../../snap/glib-core
g++  -shared -fopenmp -o _snap.so snap_wrap.o Snap.o cliques.o agm.o agmfast.o agmfit.o -lrt
make[1]: Leaving directory `/home/pablo/SD64/Dev/Snap/snap-python/swig'

GetRndNI() is not wrapped like GetNI()

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. :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.