• Stars
    star
    294
  • Rank 141,303 (Top 3 %)
  • Language
    C++
  • License
    Other
  • Created almost 12 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

SNAP Python code, SWIG related files

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

More Repositories

1

snap

Stanford Network Analysis Platform (SNAP) is a general purpose network analysis and graph mining library.
C++
2,167
star
2

ogb

Benchmark datasets, data loaders, and evaluators for graph machine learning
Python
1,906
star
3

GraphGym

Platform for designing and evaluating Graph Neural Networks (GNN)
Python
1,669
star
4

pretrain-gnns

Strategies for Pre-training Graph Neural Networks
Python
955
star
5

deepsnap

Python library assists deep learning on graphs
Python
546
star
6

GraphRNN

Python
408
star
7

med-flamingo

Python
375
star
8

neural-subgraph-learning-GNN

Jupyter Notebook
327
star
9

stark

STaRK: Benchmarking LLM Retrieval on Textual and Relational Knowledge Bases (NeurIPS D&B 2024)
Python
297
star
10

cs224w-notes

CS224W Course Notes
CSS
292
star
11

KGReasoning

Multi-Hop Logical Reasoning in Knowledge Graphs
Python
274
star
12

GreaseLM

[ICLR 2022 spotlight]GreaseLM: Graph REASoning Enhanced Language Models for Question Answering
Python
229
star
13

MLAgentBench

Python
224
star
14

relbench

RelBench: Relational Deep Learning Benchmark
Python
193
star
15

GEARS

GEARS is a geometric deep learning model that predicts outcomes of novel multi-gene perturbations
Python
189
star
16

distance-encoding

Distance Encoding for GNN Design
Jupyter Notebook
181
star
17

graphwave

Jupyter Notebook
169
star
18

UCE

UCE is a zero-shot foundation model for single-cell gene expression data
Python
158
star
19

covid-mobility

Jupyter Notebook
148
star
20

roland

Jupyter Notebook
125
star
21

GIB

Graph Information Bottleneck (GIB) for learning minimal sufficient structural and feature information using GNNs
Jupyter Notebook
123
star
22

mars

Discovering novel cell types across heterogenous single-cell experiments
Jupyter Notebook
119
star
23

comet

[ICLR 2021] Concept Learners for Few-Shot Learning
Python
111
star
24

SATURN

Jupyter Notebook
103
star
25

orca

[ICLR 2022] Open-World Semi-Supervised Learning
Python
85
star
26

prodigy

Python
75
star
27

CAW

Python
72
star
28

snapvx

Python
65
star
29

conformalized-gnn

Uncertainty Quantification over Graph with Conformalized Graph Neural Networks (NeurIPS 2023)
Python
64
star
30

multiscale-interactome

Python
62
star
31

plato

Python
61
star
32

miner-data

Python
60
star
33

stellar

Jupyter Notebook
58
star
34

mambo

Jupyter Notebook
37
star
35

lamp

[ICLR23] First deep learning-based surrogate model that jointly learns the evolution model and optimizes computational cost via remeshing
Python
36
star
36

crust

[NeurIPS 2020] Coresets for Robust Training of Neural Networks against Noisy Labels
Python
33
star
37

bc-emb

Python
32
star
38

csr

Python
30
star
39

zeroc

ZeroC is a neuro-symbolic method that trained with elementary visual concepts and relations, can zero-shot recognize and acquire more complex, hierarchical concepts, even across domains
Jupyter Notebook
28
star
40

masa

Motif-Aware State Assignment in Noisy Time Series Data
Python
24
star
41

le_pde

LE-PDE accelerates PDEs' forward simulation and inverse optimization via latent global evolution, achieving significant speedup with SOTA accuracy
Jupyter Notebook
21
star
42

ConE

Python
20
star
43

BioDiscoveryAgent

BioDiscoveryAgent is an LLM-based AI agent for closed-loop design of genetic perturbation experiments
Python
19
star
44

F-FADE

Python
17
star
45

MetroMaps

MetroMaps Release
Python
16
star
46

MAG

Programs for Microsoft Academic Graph
Python
16
star
47

snap-dev

SNAP repository for Ringo
C++
14
star
48

exposure-segregation

Python
13
star
49

ringo

Next generation graph processing platform
Python
12
star
50

planet

PlaNet: Predicting population response to drugs via clinical knowledge graph
Python
12
star
51

covid-mobility-tool

Jupyter Notebook
10
star
52

llm-social-network

Jupyter Notebook
10
star
53

reddit-processing

preprocessing of Reddit data
Python
7
star
54

ViRel

ViRel: Unsupervised Visual Relations Discovery with Graph-level Analogy
Python
7
star
55

news-search

search Internet news archive
Java
7
star
56

snap-python-64

C++
6
star
57

snap-dev-64

64-bit SNAP (in development, not intended for general use)
C++
6
star
58

snapworld

Python
6
star
59

lego

5
star
60

yperf

Simple performance monitor for Linux
Python
4
star
61

pebble-fit

become less sedentary with pebble
C
4
star
62

dec2vec

Python
3
star
63

caml

Python
3
star
64

SnapTimeTF

Python
2
star
65

covid-spillovers

Jupyter Notebook
2
star
66

curis-2012

Summer 2012 Curis Project
JavaScript
2
star
67

snaptime

Python
2
star
68

GNN-reading-group

1
star
69

supply-chains

Jupyter Notebook
1
star
70

relbench-user-study

Python
1
star
71

AutoTransfer

Python
1
star
72

hash

C++
1
star