galib 1.1.3__tar.gz → 2.0.dev0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,116 @@
1
+ .DS_Store
2
+
3
+ # Byte-compiled / optimized / DLL files
4
+ __pycache__/
5
+ *.py[cod]
6
+ *$py.class
7
+
8
+ # C extensions
9
+ *.so
10
+
11
+ # Distribution / packaging
12
+ .Python
13
+ build/
14
+ develop-eggs/
15
+ dist/
16
+ downloads/
17
+ eggs/
18
+ .eggs/
19
+ lib/
20
+ lib64/
21
+ parts/
22
+ sdist/
23
+ var/
24
+ wheels/
25
+ *.egg-info/
26
+ .installed.cfg
27
+ *.egg
28
+ MANIFEST
29
+
30
+ # PyInstaller
31
+ # Usually these files are written by a python script from a template
32
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
33
+ *.manifest
34
+ *.spec
35
+
36
+ # Installer logs
37
+ pip-log.txt
38
+ pip-delete-this-directory.txt
39
+
40
+ # Unit test / coverage reports
41
+ htmlcov/
42
+ .tox/
43
+ .nox/
44
+ .coverage
45
+ .coverage.*
46
+ .cache
47
+ nosetests.xml
48
+ coverage.xml
49
+ *.cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+
53
+ # Translations
54
+ *.mo
55
+ *.pot
56
+
57
+ # Django stuff:
58
+ *.log
59
+ local_settings.py
60
+ db.sqlite3
61
+
62
+ # Flask stuff:
63
+ instance/
64
+ .webassets-cache
65
+
66
+ # Scrapy stuff:
67
+ .scrapy
68
+
69
+ # Sphinx documentation
70
+ docs/_build/
71
+
72
+ # PyBuilder
73
+ target/
74
+
75
+ # Jupyter Notebook
76
+ .ipynb_checkpoints
77
+
78
+ # IPython
79
+ profile_default/
80
+ ipython_config.py
81
+
82
+ # pyenv
83
+ .python-version
84
+
85
+ # celery beat schedule file
86
+ celerybeat-schedule
87
+
88
+ # SageMath parsed files
89
+ *.sage.py
90
+
91
+ # Environments
92
+ .env
93
+ .venv
94
+ env/
95
+ venv/
96
+ ENV/
97
+ env.bak/
98
+ venv.bak/
99
+
100
+ # Spyder project settings
101
+ .spyderproject
102
+ .spyproject
103
+
104
+ # Rope project settings
105
+ .ropeproject
106
+
107
+ # mkdocs documentation
108
+ /site
109
+
110
+ # mypy
111
+ .mypy_cache/
112
+ .dmypy.json
113
+ dmypy.json
114
+
115
+ # Pyre type checker
116
+ .pyre/
@@ -0,0 +1,221 @@
1
+ License
2
+ =======
3
+
4
+ Copyright (c) 2018, Gorka Zamora-López <gorka@Zamora-Lopez.xyz>
5
+
6
+ Licensed under the Apache License, Version 2.0 (the "License");
7
+ you may not use this software except in compliance with the License.
8
+ You may obtain a copy of the License at
9
+
10
+ http://www.apache.org/licenses/LICENSE-2.0
11
+
12
+ Unless required by applicable law or agreed to in writing, software
13
+ distributed under the License is distributed on an "AS IS" BASIS,
14
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ See the License for the specific language governing permissions and
16
+ limitations under the License.
17
+
18
+ ::
19
+
20
+
21
+ Apache License
22
+ Version 2.0, January 2004
23
+ http://www.apache.org/licenses/
24
+
25
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
26
+
27
+ 1. Definitions.
28
+
29
+ "License" shall mean the terms and conditions for use, reproduction,
30
+ and distribution as defined by Sections 1 through 9 of this document.
31
+
32
+ "Licensor" shall mean the copyright owner or entity authorized by
33
+ the copyright owner that is granting the License.
34
+
35
+ "Legal Entity" shall mean the union of the acting entity and all
36
+ other entities that control, are controlled by, or are under common
37
+ control with that entity. For the purposes of this definition,
38
+ "control" means (i) the power, direct or indirect, to cause the
39
+ direction or management of such entity, whether by contract or
40
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
41
+ outstanding shares, or (iii) beneficial ownership of such entity.
42
+
43
+ "You" (or "Your") shall mean an individual or Legal Entity
44
+ exercising permissions granted by this License.
45
+
46
+ "Source" form shall mean the preferred form for making modifications,
47
+ including but not limited to software source code, documentation
48
+ source, and configuration files.
49
+
50
+ "Object" form shall mean any form resulting from mechanical
51
+ transformation or translation of a Source form, including but
52
+ not limited to compiled object code, generated documentation,
53
+ and conversions to other media types.
54
+
55
+ "Work" shall mean the work of authorship, whether in Source or
56
+ Object form, made available under the License, as indicated by a
57
+ copyright notice that is included in or attached to the work
58
+ (an example is provided in the Appendix below).
59
+
60
+ "Derivative Works" shall mean any work, whether in Source or Object
61
+ form, that is based on (or derived from) the Work and for which the
62
+ editorial revisions, annotations, elaborations, or other modifications
63
+ represent, as a whole, an original work of authorship. For the purposes
64
+ of this License, Derivative Works shall not include works that remain
65
+ separable from, or merely link (or bind by name) to the interfaces of,
66
+ the Work and Derivative Works thereof.
67
+
68
+ "Contribution" shall mean any work of authorship, including
69
+ the original version of the Work and any modifications or additions
70
+ to that Work or Derivative Works thereof, that is intentionally
71
+ submitted to Licensor for inclusion in the Work by the copyright owner
72
+ or by an individual or Legal Entity authorized to submit on behalf of
73
+ the copyright owner. For the purposes of this definition, "submitted"
74
+ means any form of electronic, verbal, or written communication sent
75
+ to the Licensor or its representatives, including but not limited to
76
+ communication on electronic mailing lists, source code control systems,
77
+ and issue tracking systems that are managed by, or on behalf of, the
78
+ Licensor for the purpose of discussing and improving the Work, but
79
+ excluding communication that is conspicuously marked or otherwise
80
+ designated in writing by the copyright owner as "Not a Contribution."
81
+
82
+ "Contributor" shall mean Licensor and any individual or Legal Entity
83
+ on behalf of whom a Contribution has been received by Licensor and
84
+ subsequently incorporated within the Work.
85
+
86
+ 2. Grant of Copyright License. Subject to the terms and conditions of
87
+ this License, each Contributor hereby grants to You a perpetual,
88
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
89
+ copyright license to reproduce, prepare Derivative Works of,
90
+ publicly display, publicly perform, sublicense, and distribute the
91
+ Work and such Derivative Works in Source or Object form.
92
+
93
+ 3. Grant of Patent License. Subject to the terms and conditions of
94
+ this License, each Contributor hereby grants to You a perpetual,
95
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
96
+ (except as stated in this section) patent license to make, have made,
97
+ use, offer to sell, sell, import, and otherwise transfer the Work,
98
+ where such license applies only to those patent claims licensable
99
+ by such Contributor that are necessarily infringed by their
100
+ Contribution(s) alone or by combination of their Contribution(s)
101
+ with the Work to which such Contribution(s) was submitted. If You
102
+ institute patent litigation against any entity (including a
103
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
104
+ or a Contribution incorporated within the Work constitutes direct
105
+ or contributory patent infringement, then any patent licenses
106
+ granted to You under this License for that Work shall terminate
107
+ as of the date such litigation is filed.
108
+
109
+ 4. Redistribution. You may reproduce and distribute copies of the
110
+ Work or Derivative Works thereof in any medium, with or without
111
+ modifications, and in Source or Object form, provided that You
112
+ meet the following conditions:
113
+
114
+ (a) You must give any other recipients of the Work or
115
+ Derivative Works a copy of this License; and
116
+
117
+ (b) You must cause any modified files to carry prominent notices
118
+ stating that You changed the files; and
119
+
120
+ (c) You must retain, in the Source form of any Derivative Works
121
+ that You distribute, all copyright, patent, trademark, and
122
+ attribution notices from the Source form of the Work,
123
+ excluding those notices that do not pertain to any part of
124
+ the Derivative Works; and
125
+
126
+ (d) If the Work includes a "NOTICE" text file as part of its
127
+ distribution, then any Derivative Works that You distribute must
128
+ include a readable copy of the attribution notices contained
129
+ within such NOTICE file, excluding those notices that do not
130
+ pertain to any part of the Derivative Works, in at least one
131
+ of the following places: within a NOTICE text file distributed
132
+ as part of the Derivative Works; within the Source form or
133
+ documentation, if provided along with the Derivative Works; or,
134
+ within a display generated by the Derivative Works, if and
135
+ wherever such third-party notices normally appear. The contents
136
+ of the NOTICE file are for informational purposes only and
137
+ do not modify the License. You may add Your own attribution
138
+ notices within Derivative Works that You distribute, alongside
139
+ or as an addendum to the NOTICE text from the Work, provided
140
+ that such additional attribution notices cannot be construed
141
+ as modifying the License.
142
+
143
+ You may add Your own copyright statement to Your modifications and
144
+ may provide additional or different license terms and conditions
145
+ for use, reproduction, or distribution of Your modifications, or
146
+ for any such Derivative Works as a whole, provided Your use,
147
+ reproduction, and distribution of the Work otherwise complies with
148
+ the conditions stated in this License.
149
+
150
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
151
+ any Contribution intentionally submitted for inclusion in the Work
152
+ by You to the Licensor shall be under the terms and conditions of
153
+ this License, without any additional terms or conditions.
154
+ Notwithstanding the above, nothing herein shall supersede or modify
155
+ the terms of any separate license agreement you may have executed
156
+ with Licensor regarding such Contributions.
157
+
158
+ 6. Trademarks. This License does not grant permission to use the trade
159
+ names, trademarks, service marks, or product names of the Licensor,
160
+ except as required for reasonable and customary use in describing the
161
+ origin of the Work and reproducing the content of the NOTICE file.
162
+
163
+ 7. Disclaimer of Warranty. Unless required by applicable law or
164
+ agreed to in writing, Licensor provides the Work (and each
165
+ Contributor provides its Contributions) on an "AS IS" BASIS,
166
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
167
+ implied, including, without limitation, any warranties or conditions
168
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
169
+ PARTICULAR PURPOSE. You are solely responsible for determining the
170
+ appropriateness of using or redistributing the Work and assume any
171
+ risks associated with Your exercise of permissions under this License.
172
+
173
+ 8. Limitation of Liability. In no event and under no legal theory,
174
+ whether in tort (including negligence), contract, or otherwise,
175
+ unless required by applicable law (such as deliberate and grossly
176
+ negligent acts) or agreed to in writing, shall any Contributor be
177
+ liable to You for damages, including any direct, indirect, special,
178
+ incidental, or consequential damages of any character arising as a
179
+ result of this License or out of the use or inability to use the
180
+ Work (including but not limited to damages for loss of goodwill,
181
+ work stoppage, computer failure or malfunction, or any and all
182
+ other commercial damages or losses), even if such Contributor
183
+ has been advised of the possibility of such damages.
184
+
185
+ 9. Accepting Warranty or Additional Liability. While redistributing
186
+ the Work or Derivative Works thereof, You may choose to offer,
187
+ and charge a fee for, acceptance of support, warranty, indemnity,
188
+ or other liability obligations and/or rights consistent with this
189
+ License. However, in accepting such obligations, You may act only
190
+ on Your own behalf and on Your sole responsibility, not on behalf
191
+ of any other Contributor, and only if You agree to indemnify,
192
+ defend, and hold each Contributor harmless for any liability
193
+ incurred by, or claims asserted against, such Contributor by reason
194
+ of your accepting any such warranty or additional liability.
195
+
196
+ END OF TERMS AND CONDITIONS
197
+
198
+ APPENDIX: How to apply the Apache License to your work.
199
+
200
+ To apply the Apache License to your work, attach the following
201
+ boilerplate notice, with the fields enclosed by brackets "[]"
202
+ replaced with your own identifying information. (Don't include
203
+ the brackets!) The text should be enclosed in the appropriate
204
+ comment syntax for the file format. We also recommend that a
205
+ file or class name and description of purpose be included on the
206
+ same "printed page" as the copyright notice for easier
207
+ identification within third-party archives.
208
+
209
+ Copyright (c) 2018, Gorka Zamora-López
210
+
211
+ Licensed under the Apache License, Version 2.0 (the "License");
212
+ you may not use this file except in compliance with the License.
213
+ You may obtain a copy of the License at
214
+
215
+ http://www.apache.org/licenses/LICENSE-2.0
216
+
217
+ Unless required by applicable law or agreed to in writing, software
218
+ distributed under the License is distributed on an "AS IS" BASIS,
219
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
220
+ See the License for the specific language governing permissions and
221
+ limitations under the License.
@@ -0,0 +1,309 @@
1
+ Metadata-Version: 2.4
2
+ Name: galib
3
+ Version: 2.0.dev0
4
+ Summary: A library for graph analysis in Python / NumPy.
5
+ Project-URL: Homepage, https://github.com/gorkazl/pyGAlib
6
+ Project-URL: Source Code, https://github.com/gorkazl/pyGAlib/tree/master/src/galib
7
+ Project-URL: Bug Tracker, https://github.com/gorkazl/pyGAlib/issues
8
+ Project-URL: Documentation, https://github.com/gorkazl/pyGAlib/blob/master/README.md
9
+ Author-email: Gorka Zamora-López <gorka@Zamora-Lopez.xyz>
10
+ License-Expression: Apache-2.0
11
+ License-File: LICENSE.txt
12
+ Keywords: complex networks,graph theory,network analysis
13
+ Classifier: Development Status :: 5 - Production/Stable
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Intended Audience :: Education
16
+ Classifier: Intended Audience :: Science/Research
17
+ Classifier: License :: OSI Approved :: Apache Software License
18
+ Classifier: Operating System :: OS Independent
19
+ Classifier: Programming Language :: Python
20
+ Classifier: Programming Language :: Python :: 3
21
+ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
22
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
23
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
24
+ Classifier: Topic :: Scientific/Engineering :: Physics
25
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
26
+ Requires-Dist: numba
27
+ Requires-Dist: numpy>=1.6
28
+ Requires-Dist: scipy
29
+ Description-Content-Type: text/markdown
30
+
31
+ [![pypi version](https://img.shields.io/pypi/v/galib?logo=pypi)](https://pypi.org/project/galib/)
32
+ [![PyPI Downloads](https://img.shields.io/pypi/dm/galib.svg?label=PyPI%20downloads)](
33
+ https://pypi.org/project/galib/)
34
+ [![Apache-2.0 License](https://img.shields.io/badge/license-Apache-blue.svg?style=flat)](http://choosealicense.com/licenses/Apache-2.0/)
35
+
36
+
37
+ # pyGAlib – Graph Analysis Library in Python / NumPy
38
+
39
+ > **Development branch**. Version 2 of pyGAlib under construction. Heavy changes expected in this branch. For download, please install the PyPI version or the one in the master branch of this repository. Both are installed via `pip`, see instructions in the corresponding README.md file.
40
+
41
+ pyGAlib is a library to generate and study graphs and complex networks in Python. It treats networks as adjacency matrices in order to take advantage of faster NumPy
42
+ array manipulations. The library is easy to install, use, modify and extend.
43
+
44
+ Main features...
45
+
46
+ - networks represented as adjacency matrices (rank-2 ndarrays);
47
+ - extensive use of NumPy for high performance over pure Python code;
48
+ - Some functions further boosted using Numba;
49
+ - transparent and flexible: find which part of the code is doing what;
50
+ - Python 3 compatible.
51
+
52
+ ... and some limitations:
53
+
54
+ - management of large networks due to NumPy dependence,
55
+ - no graph visualization tools.
56
+
57
+
58
+
59
+ ### INSTALLATION
60
+
61
+ Installation of pyGAlib is simple, only the [pip](https://github.com/pypa/pip) package manager is needed. To check whether `pip` is installed, open a terminal and type:
62
+
63
+ pip --help
64
+
65
+ > **NOTE**: If you use Anaconda (or any other third-party package manager), we recommend to install the dependencies (python>=3.6, numpy>=1.6, scipy and numba) into the target environment using Anaconda before installing pyGAlib. Otherwise, `pip` will download and install those packages directly from PyPI as well, and you won't be able to manage them through Acanconda.
66
+
67
+ #### Installing from PyPI
68
+
69
+ pyGAlib is registered in the official *Python Package Index*, [PyPI](https://pypi.org/project/galib/) . To install, open a terminal window and type:
70
+
71
+ python3 -m pip install galib
72
+
73
+ To confirm the installation, open an interactive session (e.g., IPython or a Notebook) and try to import the library by typing `import galib`.
74
+
75
+ #### Direct installation from GitHub
76
+
77
+ If you have [git](https://git-scm.com) installed, you may like to install pyGAlib directly from its GitHub repository. Open a terminal and type:
78
+
79
+ python3 -m pip install git+https://github.com/gorkazl/pyGAlib.git@master
80
+
81
+ This will only download and install the package (files in "*src/galib/*") into your current environment. If desired, additional files of the repository (e.g. the examples in the *Examples/* folder) should be downloaded manually. You can choose to install the version in another branch by replacing the '*@master*' at the end of the command by '*@branchname*' of the desired branch.
82
+
83
+ #### Installing pyGAlib in editable mode
84
+
85
+ If you want to install pyGAlib such that you can make changes to it "*on the fly*" then, visit its GitHub repository [https://github.com/gorkazl/pyGAlib/](https://github.com/gorkazl/pyGAlib/), select a branch and then click on the green "*<> Code*" button on the top right and select "Download ZIP" from the pop-up menu. Once downloaded, move the *zip* file to a target folder (e.g., "*~/Documents/myLibraries/*") and unzip the file. Open a terminal and `cd` to the resulting folder, e.g.,
86
+
87
+ cd ~/Documents/myLibraries/pyGAlib-master/
88
+
89
+ Once on the path (make sure it contains the *pyproject.toml* file), type:
90
+
91
+ python3 -m pip install -e .
92
+
93
+ Do not forget the "." at the end which means "*look for the pyproject.toml file in the current directory*." This will install pyGAlib such that every time changes are made to the package (located in the path chosen), these will be inmediately available. You may need to restart the IPython or Jupyter notebook session, though.
94
+
95
+
96
+
97
+ ### HOW TO USE pyGAlib
98
+
99
+ The library is organised in the following modules:
100
+
101
+ - *metrics.py*: Common graph metrics (degrees, clustering, graph distance, etc)
102
+ - *models.py*: Generation of synthetic networks and randomization.
103
+ - *tools.py*: Miscelaneous helper functions.
104
+ - *metrics_numba.py*: Uses the Numba package to accelerate calculation of some metrics.
105
+ - *models_numba.py*: Uses the Numba package to accelerate generation of some graph models.
106
+ - *extra.py*: Additional measures and functionalities related to network analysis.
107
+
108
+ #### Getting started
109
+
110
+ Since pyGAlib depends on NumPy, it is recommended to import NumPy first. Although
111
+ this is not necessary for loading pyGAlib, NumPy functionalities and array
112
+ manipulation will be often needed. Try importing pyGAlib:
113
+
114
+ >>> import numpy as np
115
+ >>> import galib
116
+
117
+ > **NOTE**: Importing galib imports also all functions in module *metrics.py* into its namespace. The rest of modules are imported separately. Therefore, if the import is relative those functions can be called as, e.g.,
118
+
119
+ >>> import galib
120
+ >>> ...
121
+ >>> deg = galib.Degree(net)
122
+ >>> C, Cnodes = galib.Clustering(net)
123
+
124
+ > See that we did not have to call `galib.metrics.Degree(net)`. In the case of an absolute import (using an asterisk `*`) all functions in *metrics.py* are imported to the base namespace:
125
+
126
+ >>> from galib import *
127
+ >>> ...
128
+ >>> deg = Degree(net)
129
+ >>> C, Cnodes = Clustering(net)
130
+
131
+ ##### Example
132
+
133
+ Let's generate a random graph following the Erdos-Renyi model, G(N,p), with
134
+ *N = 100* nodes and link probability *p = 0.1*:
135
+
136
+ >>> import galib
137
+ >>> import galib.models
138
+ >>> N = 100; p = 0.1
139
+ >>> net = galib.models.ErdosRenyiGraph(N, p, directed=False)
140
+
141
+ Here, *net* is the adjacency matrix of the random graph represented as a
142
+ 2-dimensional NumPy array. Let's calculate some basic properties.
143
+
144
+ >>> galib.Density(net)
145
+ 0.09838383838383838
146
+
147
+ As expected, the density of an Erdos-Renyi random graph is close to the *p = 0.1* value given. We now calculate the degree of every node:
148
+
149
+ >>> deg = galib.Degree(net)
150
+ >>> deg
151
+ array([10, 7, 10, 10, 11, 7, 5, 11, 13, 12, 14, 13, 8, 10, 9, 8, 7,
152
+ 10, 11, 9, 11, 11, 8, 10, 5, 9, 13, 10, 13, 12, 12, 11, 11, 7,
153
+ 13, 11, 7, 10, 10, 6, 12, 10, 6, 10, 7, 6, 9, 10, 9, 9, 7,
154
+ 9, 8, 13, 10, 9, 7, 7, 11, 8, 13, 6, 7, 12, 14, 6, 5, 11,
155
+ 5, 12, 14, 14, 13, 8, 7, 12, 4, 19, 9, 13, 7, 10, 15, 15, 4,
156
+ 9, 7, 12, 7, 8, 12, 4, 11, 12, 6, 13, 6, 12, 16, 12])
157
+
158
+ The degree is returned as a numpy array of rank 1, of integer type. The function *Clustering* returns both the global clustering coefficient and the local clustering of every node:
159
+
160
+ >>> C, Cnodes = galib.Clustering(net)
161
+ >>> C
162
+ 0.096051227321238
163
+ >>> Cnodes
164
+ array([0.13333333, 0.04761905, 0.04444444, 0.08888889, 0.10909091,
165
+ 0.19047619, 0.3 , 0.12727273, 0.08974359, 0.06060606,
166
+ ... ... ...
167
+ ... ... ...
168
+ 0.04545455, 0. , 0.10909091, 0.13636364, 0. ,
169
+ 0.07692308, 0.13333333, 0.09090909, 0.08333333, 0.10606061])
170
+
171
+ We compute the pair-wise graph distance between all the nodes using the Floyd-Warshall algorithm, which is returned as a matrix *dij* (numpy array of rank 2):
172
+
173
+ >>> dij = galib.FloydWarshall(net)
174
+ >>> avlen = (dij.sum() - dij.trace()) / (N*(N-1))
175
+ >>> avlen
176
+ 2.248080808080808
177
+
178
+ > **NOTE:** For calculating the distance matrix of larger networks please use the version of the function located in the module *metrics_numba.py*. Here, the function `FloydWarshall_Numba()` works the same but makes use of the Numba library to significantly speed the calculation.
179
+
180
+ Most network generators and graph metrics in pyGAlib work with directed graphs as well. Check for the optional parameter `directed`. Following the example above, we generate a directed Erdos-Renyi graph and calculate its input and output degrees for every node:
181
+
182
+ >>> net = galib.models.ErdosRenyiGraph(N, p, directed=True)
183
+ >>> galib.Density(net)
184
+ 0.10272727272727272
185
+ >>> indeg, outdeg = galib.Degree(net, directed=True)
186
+ >>> indeg
187
+ array([17, 7, 9, 8, 11, 10, 9, 8, 13, 13, 5, 9, 13, 9, 10, 10, 13,
188
+ 10, 9, 9, 7, 11, 13, 10, 4, 15, 11, 11, 10, 6, 6, 8, 8, 8,
189
+ 11, 8, 4, 12, 8, 13, 13, 14, 12, 5, 6, 5, 16, 12, 5, 10, 9,
190
+ 13, 8, 9, 7, 8, 13, 14, 9, 18, 7, 11, 5, 4, 12, 8, 8, 10,
191
+ 7, 9, 15, 12, 14, 9, 15, 11, 13, 12, 15, 10, 11, 11, 15, 7, 10,
192
+ 13, 7, 14, 9, 16, 11, 11, 6, 18, 7, 4, 14, 12, 12, 10])
193
+ >>> outdeg
194
+ array([ 9, 10, 7, 9, 12, 9, 19, 9, 11, 16, 11, 12, 11, 15, 11, 6, 9,
195
+ 8, 11, 12, 9, 13, 9, 8, 11, 6, 7, 11, 11, 12, 10, 8, 11, 12,
196
+ 10, 12, 13, 8, 18, 11, 8, 13, 10, 8, 10, 10, 11, 8, 11, 11, 11,
197
+ 10, 11, 10, 9, 12, 6, 10, 7, 10, 10, 11, 15, 12, 11, 7, 10, 8,
198
+ 5, 11, 7, 11, 13, 8, 5, 6, 13, 11, 10, 13, 7, 6, 13, 11, 8,
199
+ 8, 10, 6, 10, 9, 12, 15, 11, 9, 15, 11, 7, 8, 11, 10])
200
+
201
+ ##### Data I/O
202
+
203
+ Since GAlib is based on NumPy arrays, saving and reading of adjacency matrices,
204
+ as well as any other output of GAlib functions, can be performed using the
205
+ usual data I/O functionalities of NumPy. See for example the documentation for functions: `loadtxt()`, `savetxt()`, `load()`, `save()` and `savez()`. The *tools.py* module in pyGAlib provides also some data conversion functionalities.
206
+
207
+
208
+
209
+ ### HOW TO FIND FURTHER DOCUMENTATION
210
+
211
+ While working in an interactive session, after importing a module, the built-in `help()` function will show further details:
212
+
213
+ >>> help(modulename)
214
+
215
+ The help for galib (`help(galib)`) shows the general summary of the package and a list of all the modules in the library. The help for each module, e.g., `help(galib.metrics)` or `help(galib.models)` will display module specific information and a list of all the functions in the module.
216
+ For further details regarding each function, type:
217
+
218
+ >>> help(galib.modulename.functionname)
219
+
220
+ IPython and Jupyter notebook users, the help command is replaced by a question mark after the module's or function's name, e.g.:
221
+
222
+ >>> modulename?
223
+ >>> functionname?
224
+
225
+ For questions, bug reports, etc, please write to <gorka@Zamora-Lopez.xyz>, or open an issue in GitHub.
226
+
227
+
228
+ ### FUTURE DEVELOPMENTS
229
+
230
+ See the *[TODO.md](https://github.com/gorkazl/pyGAlib/blob/master/TODO.md)* file in the GitHub Repository.
231
+ **Collaborations to extend pyGAlib are welcome.** If you have experience using *scipy.sparse*, developing community detection methods or coding graph visualization, please, please, contact me.
232
+
233
+
234
+ ### LICENSE
235
+ Copyright (c) 2018, Gorka Zamora-López, <<gorka@Zamora-Lopez.xyz>>
236
+
237
+ Licensed under the Apache License, Version 2.0 (the "License");
238
+ you may not use this software except in compliance with the License.
239
+ You may obtain a copy of the License at
240
+
241
+ [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
242
+
243
+ Unless required by applicable law or agreed to in writing, software
244
+ distributed under the License is distributed on an "AS IS" BASIS,
245
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
246
+ See the License for the specific language governing permissions and
247
+ limitations under the License.
248
+
249
+ **Note:** Please, use the logos provided in the *Branding/* folder whenever possible.
250
+
251
+
252
+
253
+ -----------------------------------------------------------------
254
+ ### WHAT IS NEW
255
+
256
+ ##### November 10, 2025 (Release of Version 2)
257
+
258
+ Stable version 2.0 checked, validated and released.
259
+
260
+ * Python 2 support has been dropped. Only Python 3 compatibility will be developed and maintained from now on.
261
+ * The library has been reshaped to be compliant with the modern [PyPA specifications](https://packaging.python.org/en/latest/specifications/).
262
+ * [Hatch](https://hatch.pypa.io/latest/) was chosen as the tool to build and publish the package. See the *pyproject.toml* file.
263
+ * Bug fixes to adapt to the various changes in Python and NumPy since last release.
264
+ * Sample and validation scripts in the "*Examples/*" folder revised and adapted to recent changes in Python and NumPy.
265
+
266
+ ##### March 14, 2024
267
+ Small bugs fixed:
268
+
269
+ - Normalization of `galib.metrics.Modularity()` function corrected.
270
+ - Fixed the new aliases for `int` and `float` in *Numpy*. All arrays are now declared as `np.int64` or `np.float64`, and individual numbers as standard Python `int` or `float`.
271
+
272
+ ##### February 7, 2022
273
+ Minor bug fixes. A remaining Python 2 to Python 3 conversion error was fixed, since standard library function `range()` no longer returns a list, but an iterator object.
274
+
275
+ ##### June 15, 2020
276
+ Docstrings corrected. Function `k_DensityW()` was added in module *metrics.py* to calculate the k-density in networks with weighted links, which is needed to evaluate potential formation of rich-club structures in weigthed networks.
277
+
278
+ ##### July 12, 2019
279
+ Version 1.1.0 released. Section for classic and deterministic graphs added to the *models.py* module. New generators `PathGraph()`, `StarGraph()` and `CompleteGraph()` included.
280
+
281
+ ##### July 6, 2019
282
+ For clarity, function `RichClub()` has been splitted into two functions: `RichClub()`and `k_Density()`. The reason is that the output of old `RichClub()` was basically the k-density for all degrees, from 0 to kmax. Now this is done by `k_Density()` and the new `RichClub()` function identifies the set of nodes (hubs) for which k-density overcomes a given value.
283
+
284
+ ##### June 15, 2019
285
+ GAlib has been registered in PyPI ([https://pypi.org/project/galib/](https://pypi.org/project/galib/)). Direct installation and version management using `pip` is thus available.
286
+
287
+ ##### January 29, 2019
288
+ New in Version 1.0.1:
289
+
290
+ - Minor corrections overall.
291
+ - Function to generate Ravasz-Barabási hierarchical networks added to *models.py* module.
292
+
293
+ ##### December 3, 2018
294
+ Release of Version 1.0.0 of pyGAlib. The library is now shaped as a proper Python package and is installable using standard tools. The structure of the package has been renewed and contains the following modules:
295
+
296
+ - *metrics.py*: Common graph metrics (degrees, clustering, graph distance, etc)
297
+ - *models.py*: Generation of synthetic networks and randomization.
298
+ - *tools.py*: Miscelaneous helper functions.
299
+ - *metrics_numba.py*: Uses the Numba package to accelerate calculation of some metrics.
300
+ - *models_numba.py*: Uses the Numba package to accelerate generation of some graph models.
301
+ - *extra.py*: Additional measures and functionalities related to network analysis.
302
+
303
+ See the file *CHANGELOG.md* for a complete history of changes.
304
+
305
+
306
+
307
+
308
+
309
+