-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 68e3092
Showing
36 changed files
with
3,146 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
### CMake ### | ||
CMakeCache.txt | ||
CMakeFiles | ||
CMakeScripts | ||
Makefile | ||
cmake_install.cmake | ||
install_manifest.txt | ||
.deps | ||
.dirstamp | ||
|
||
### C++ ### | ||
# Compiled Object files | ||
*.slo | ||
*.lo | ||
*.o | ||
*.obj | ||
|
||
# Precompiled Headers | ||
*.gch | ||
*.pch | ||
|
||
# Compiled Dynamic libraries | ||
*.so | ||
*.dylib | ||
*.dll | ||
|
||
# Fortran module files | ||
*.mod | ||
|
||
# Compiled Static libraries | ||
*.lai | ||
*.la | ||
*.a | ||
*.lib | ||
|
||
# Executables | ||
*.exe | ||
*.out | ||
*.app | ||
|
||
doc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
language: cpp | ||
os: | ||
- linux | ||
- osx | ||
compiler: | ||
- gcc | ||
- clang | ||
cache: | ||
apt: true | ||
addons: | ||
apt: | ||
sources: | ||
- llvm-toolchain-precise | ||
- ubuntu-toolchain-r-test | ||
- boost-latest | ||
packages: | ||
- clang-3.7 | ||
- g++-4.7 | ||
- gcc-4.7 | ||
- libboost1.55-all-dev | ||
notifications: | ||
email: false | ||
script: | ||
- cmake .; make; ./spa_networks -c test_conf.txt | tee /dev/tty | wc -l; | ||
- cmake -DOPTMEM_MODE=ON -DDEBUG_MODE=OFF .; make; ./spa_networks -c test_conf.txt | tee /dev/tty | wc -l; | ||
- cmake -DOPTMEM_MODE=OFF -DDEBUG_MODE=ON .; make; ./spa_networks -c test_conf.txt | tee /dev/tty | wc -l; | ||
- cmake -DHPC_MODE=OFF -DDEBUG_MODE=OFF -DOPTMEM_MODE=OFF .; make; ./spa_networks -c test_conf.txt | tee /dev/tty | wc -l; | ||
- cmake -DFORCE_NO_BOOST=ON .; make; ./spa_networks -c test_conf.txt | tee /dev/tty | wc -l; | ||
- cmake -DFORCE_NO_STEADY_CLOCK=ON .; make; ./spa_networks -c test_conf.txt | tee /dev/tty | wc -l; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
Authors of SPA | ||
|
||
Jean-Gabriel Young implemented this simulation of the SPA (Structural | ||
Preferential Attachment) stochastic process. | ||
|
||
The SPA process is introduced in : | ||
|
||
"Structural preferential attachment: | ||
Network organization beyond the link" | ||
L. Hébert-Dufresne, A. Allard, V. Marceau, P.-A. Noël, and L.J. Dubé | ||
Phys. Rev. Lett. 107, 158702, (2011) | ||
http://arxiv.org/abs/1105.5980 | ||
|
||
and the community structure it creates is studied extensively in : | ||
|
||
"Structural preferential attachment: | ||
Stochastic process for the growth of scale-free, | ||
modular and self-similar systems" | ||
L. Hébert-Dufresne, A. Allard, V. Marceau, P.-A. Noël, and L.J. Dubé | ||
Phys. Rev. E 85, 026108, (2012) | ||
http://arxiv.org/abs/1109.0034 | ||
|
||
A local extension that incorporates an explicit link creation mechanism | ||
is presented in : | ||
|
||
"Structural preferential attachment of community structure | ||
and its relation to Dunbar’s number" | ||
J.-G. Young, L. Hébert-Dufresne, A. Allard and L.J. Dubé | ||
|
||
This C++11 simulation implements the complete version (all three | ||
publications). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
# ~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
# Project | ||
# ~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
cmake_minimum_required(VERSION 2.8) | ||
project (SPA_networks_generator) | ||
|
||
# ~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
# Check for functionalities | ||
# ~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
# Check for C++ 11 with CMAKE v.2.8 | ||
# Note: there exists a cleaner method in CMAKE 3.1+ [target_compile_features()] | ||
# but stable Debian distributions tend to distribute CMAKE 2.8 as the default. | ||
# | ||
# Solution found @ http://stackoverflow.com/a/25836953/1851837. | ||
include(CheckCXXCompilerFlag) | ||
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) | ||
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X) | ||
if(COMPILER_SUPPORTS_CXX11) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") | ||
elseif(COMPILER_SUPPORTS_CXX0X) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") | ||
else() | ||
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.") | ||
endif() | ||
|
||
# Boost | ||
find_package( Boost 1.40 COMPONENTS program_options ) | ||
if (Boost_FOUND) | ||
set(HAVE_LIBBOOST_PROGRAM_OPTIONS 1) | ||
else() | ||
message(STATUS "C++ Boost::program_options is not installed. Using limited interface.") | ||
set(HAVE_LIBBOOST_PROGRAM_OPTIONS 0) | ||
endif () | ||
|
||
# Steady clock (Google code) | ||
include(cmake_tests/CXXFeatureCheck.cmake) | ||
# If successful, then HAVE_STEADY_CLOCK is set to 1 | ||
set(HAVE_STEADY_CLOCK 0) | ||
cxx_feature_check(STEADY_CLOCK) | ||
|
||
# ~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
# Options | ||
# ~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
option(HPC_MODE | ||
"Enable high-performance mode: no output and compiles assertions out." OFF) | ||
|
||
option(OPTMEM_MODE | ||
"Enable memory optimized mode, i.e. a small memory footprint is preferred over speed." OFF) | ||
|
||
option (DEBUG_MODE | ||
"Enable debugging, i.e. full logging and assertion checks. (overrides HPC mode)." OFF) | ||
|
||
option (FORCE_NO_BOOST | ||
"Do not use boost::program_options." OFF) | ||
|
||
option (FORCE_NO_STEADY_CLOCK | ||
"Do not use std::steady_clock." OFF) | ||
|
||
# Defaults | ||
set (MEMORY_OPTIMIZED 0) | ||
set (REMOVE_ASSERTS 1) | ||
set (LOGGER_LEVEL 2) | ||
|
||
if (HPC_MODE) | ||
set (LOGGER_LEVEL 3) | ||
endif() | ||
|
||
if (OPTMEM_MODE) | ||
set (MEMORY_OPTIMIZED 1) | ||
endif() | ||
|
||
if (DEBUG_MODE) | ||
set (LOGGER_LEVEL 0) | ||
set (REMOVE_ASSERTS 0) | ||
endif() | ||
|
||
if (FORCE_NO_BOOST) | ||
set (HAVE_LIBBOOST_PROGRAM_OPTIONS 0) | ||
endif() | ||
|
||
if (FORCE_NO_STEADY_CLOCK) | ||
set (STEADY_CLOCK 0) | ||
endif() | ||
# ~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
# Build | ||
# ~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
configure_file ( | ||
"${PROJECT_SOURCE_DIR}/src/config.h.in" | ||
"${PROJECT_BINARY_DIR}/src/config.h" | ||
) | ||
include_directories("${PROJECT_BINARY_DIR}") | ||
|
||
add_subdirectory(src) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2014-2015 Jean-Gabriel Young | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# Structural Preferential Attachment Simulation [![Build Status](https://travis-ci.org/spa-networks/spa.svg?branch=master)](https://travis-ci.org/spa-networks/spa) | ||
|
||
## About: | ||
|
||
This is a C++ implementation of the stochastic growth process dubbed Structural Preferential Attachment (SPA). | ||
See [our official website](http://www.spa-networks.org/) for more informations. | ||
|
||
## Quick start | ||
|
||
### Compilation | ||
|
||
|
||
`spa_networks` uses features from C++11 and must therefore be compiled with `gcc-4.6` or `clang-3.7` (or a newer version). | ||
|
||
#### Using cmake | ||
|
||
Compiling with cmake should be straightforward: | ||
|
||
cmake . | ||
make | ||
|
||
The available options for `cmake` are | ||
|
||
* `OPTMEM_MODE` | ||
* `HPC_MODE` | ||
* `FORCE_NO_BOOST` | ||
|
||
`OPTMEM_MODE` favors a small memory footprint over speed. | ||
|
||
`HPC_MODE` silences all output and compiles assertions out. | ||
|
||
The options can be passed to the usual GUI or through the command line interface: | ||
|
||
cmake -DOPTMEM_MODE=ON . | ||
make | ||
|
||
The build [has been test](https://magnum.travis-ci.com/jg-you/spa) with `cmake-2.8` and `cmake-3.4`. | ||
|
||
#### Using g++ | ||
|
||
The explicit compilation call below should work on most Unix systems | ||
|
||
g++ -o3 -W -Wall -Wextra -pedantic -std=c++0x spa_main.cpp modular_structure.cpp spa_network.cpp subgraph.cpp spa_algorithm.cpp interface.cpp output_functions.cpp misc_functions.cpp includes/logger.cpp -lboost_program_options -o SPA | ||
|
||
Compilations options can be manually adjusted in the [src/config.h](src/config.h) file. | ||
|
||
### Execution | ||
|
||
Multiple parameters must be set for each simulation of the SPA process. | ||
These parameters can be passed through a configuration file | ||
|
||
./spa_networks -c path/to/config/file.txt | ||
|
||
Note that `./spa_networks -g` generates an empty configuration file template. | ||
If `boost::program_options` is installed and properly linked to the binary, parameters will also be accepted directly from the command line. See | ||
|
||
./spa_networks -h | ||
|
||
for more information about each flags. | ||
|
||
### Output | ||
|
||
The results of a simulation run are outputted in the directory from which `spa_networks` is called. | ||
This default behavior can be modified with the `-B / --base_path=` flag (by specifying a new absolute or relative path). | ||
Note that outputs are *not* computed unless specifically requested. | ||
So, for example, there won't be an edge list file, unless the user specifies a file name for the edge_list. e.g. `--edge_list=TestEdgeList.txt`. | ||
|
||
## Papers: | ||
|
||
More information about the SPA process is available in the following papers. | ||
|
||
### Growth at the level of communities: | ||
|
||
* [Structural preferential attachment: Network organization beyond the link](http://arxiv.org/abs/1105.5980) | ||
* [Structural preferential attachment: Stochastic process for the growth of scale-free, modular and self-similar systems](http://arxiv.org/abs/1109.0034) | ||
|
||
### Growth within a community | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# This files has been copied from https://github.com/google/benchmark/cmake/ | ||
# Distributed under the Apache License Version 2.0. | ||
# https://github.com/google/benchmark/LICENSE | ||
# Modified on Dec. 22th 2015 by Jean-Gabriel Young <jean.gabriel.young@gmail.com> | ||
# | ||
# - Compile and run code to check for C++ features | ||
# | ||
# This functions compiles a source file under the `cmake` folder | ||
# and adds the corresponding `HAVE_[FILENAME]` flag to the CMake | ||
# environment | ||
# | ||
# cxx_feature_check(<FLAG> [<VARIANT>]) | ||
# | ||
# - Example | ||
# | ||
# include(CXXFeatureCheck) | ||
# cxx_feature_check(STD_REGEX) | ||
# Requires CMake 2.6+ | ||
|
||
if(__cxx_feature_check) | ||
return() | ||
endif() | ||
set(__cxx_feature_check INCLUDED) | ||
|
||
function(cxx_feature_check FILE) | ||
string(TOLOWER ${FILE} FILE) | ||
string(TOUPPER ${FILE} VAR) | ||
string(TOUPPER "HAVE_${VAR}" FEATURE) | ||
message("-- Performing Test ${FEATURE}") | ||
try_run(RUN_${FEATURE} COMPILE_${FEATURE} | ||
${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/cmake_tests/${FILE}.cpp) | ||
if(RUN_${FEATURE} EQUAL 0) | ||
message("-- Performing Test ${FEATURE} -- success") | ||
set(HAVE_${VAR} 1 PARENT_SCOPE) | ||
add_definitions(-DHAVE_${VAR}) | ||
else() | ||
if(NOT COMPILE_${FEATURE}) | ||
message("-- Performing Test ${FEATURE} -- failed to compile") | ||
else() | ||
message("-- Performing Test ${FEATURE} -- compiled but failed to run") | ||
endif() | ||
endif() | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// This files has been copied from https://github.com/google/benchmark/cmake/ | ||
// Distributed under the Apache License Version 2.0. | ||
// https://github.com/google/benchmark/LICENSE | ||
// Modified on Dec. 22th 2015 by Jean-Gabriel Young <jean.gabriel.young@gmail.com> | ||
#include <chrono> | ||
|
||
int main() { | ||
typedef std::chrono::steady_clock Clock; | ||
Clock::time_point tp = Clock::now(); | ||
((void)tp); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
add_subdirectory(includes) | ||
|
||
if (Boost_FOUND) | ||
include_directories(${BOOST_INCLUDEDIR}) | ||
endif (Boost_FOUND) | ||
|
||
add_executable(spa_networks spa_main.cpp modular_structure.cpp spa_network.cpp subgraph.cpp spa_algorithm.cpp interface.cpp output_functions.cpp misc_functions.cpp) | ||
target_link_libraries (spa_networks logger) | ||
set_target_properties(spa_networks PROPERTIES RUNTIME_OUTPUT_DIRECTORY ../ ) | ||
|
||
if (Boost_FOUND) | ||
target_link_libraries(spa_networks ${Boost_LIBRARIES}) | ||
endif (Boost_FOUND) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#define HAVE_LIBBOOST_PROGRAM_OPTIONS @HAVE_LIBBOOST_PROGRAM_OPTIONS@ | ||
#define HAVE_STEADY_CLOCK @HAVE_STEADY_CLOCK@ | ||
#define LOGGER_LEVEL @LOGGER_LEVEL@ | ||
#define MEMORY_OPTIMIZED @MEMORY_OPTIMIZED@ | ||
#define REMOVE_ASSERTS @REMOVE_ASSERTS@ | ||
|
||
#if REMOVE_ASSERTS == 1 | ||
#define NDEBUG 1 | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#ifndef ERRORS_HPP | ||
#define ERRORS_HPP | ||
|
||
#define STOP_WITH_SUCCESS 100 | ||
#define FILE_ERROR 101 | ||
#define LOGIC_ERROR 102 | ||
#define ELEM_MISSING_ERROR 103 | ||
|
||
#endif // ERRORS_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
add_library(logger logger.cpp) |
Oops, something went wrong.