├── examples └── temp.py ├── requirements.txt ├── requirements ├── doc.txt ├── extra.txt ├── test.txt ├── developer.txt └── default.txt ├── .coveragerc ├── MANIFEST.in ├── tests ├── data │ ├── target_predictions │ │ └── adamic_adar_with_name.csv │ └── inputs │ │ ├── id_labels.csv │ │ └── neighbour_matrix.csv └── unit │ └── tests.py ├── .travis.yml ├── docs ├── build │ ├── html │ │ ├── objects.inv │ │ ├── _static │ │ │ ├── file.png │ │ │ ├── minus.png │ │ │ ├── plus.png │ │ │ ├── fonts │ │ │ │ ├── Lato-Bold.ttf │ │ │ │ ├── Inconsolata.ttf │ │ │ │ ├── Lato-Regular.ttf │ │ │ │ ├── Lato │ │ │ │ │ ├── lato-bold.eot │ │ │ │ │ ├── lato-bold.ttf │ │ │ │ │ ├── lato-bold.woff │ │ │ │ │ ├── lato-bold.woff2 │ │ │ │ │ ├── lato-italic.eot │ │ │ │ │ ├── lato-italic.ttf │ │ │ │ │ ├── lato-italic.woff │ │ │ │ │ ├── lato-italic.woff2 │ │ │ │ │ ├── lato-regular.eot │ │ │ │ │ ├── lato-regular.ttf │ │ │ │ │ ├── lato-regular.woff │ │ │ │ │ ├── lato-regular.woff2 │ │ │ │ │ ├── lato-bolditalic.eot │ │ │ │ │ ├── lato-bolditalic.ttf │ │ │ │ │ ├── lato-bolditalic.woff │ │ │ │ │ └── lato-bolditalic.woff2 │ │ │ │ ├── Inconsolata-Bold.ttf │ │ │ │ ├── RobotoSlab-Bold.ttf │ │ │ │ ├── Inconsolata-Regular.ttf │ │ │ │ ├── RobotoSlab-Regular.ttf │ │ │ │ ├── fontawesome-webfont.eot │ │ │ │ ├── fontawesome-webfont.ttf │ │ │ │ ├── fontawesome-webfont.woff │ │ │ │ ├── fontawesome-webfont.woff2 │ │ │ │ └── RobotoSlab │ │ │ │ │ ├── roboto-slab-v7-bold.eot │ │ │ │ │ ├── roboto-slab-v7-bold.ttf │ │ │ │ │ ├── roboto-slab-v7-bold.woff │ │ │ │ │ ├── roboto-slab-v7-bold.woff2 │ │ │ │ │ ├── roboto-slab-v7-regular.eot │ │ │ │ │ ├── roboto-slab-v7-regular.ttf │ │ │ │ │ ├── roboto-slab-v7-regular.woff │ │ │ │ │ └── roboto-slab-v7-regular.woff2 │ │ │ ├── css │ │ │ │ ├── fonts │ │ │ │ │ ├── lato-bold.woff │ │ │ │ │ ├── lato-bold.woff2 │ │ │ │ │ ├── lato-normal.woff │ │ │ │ │ ├── lato-normal.woff2 │ │ │ │ │ ├── Roboto-Slab-Bold.woff │ │ │ │ │ ├── lato-bold-italic.woff │ │ │ │ │ ├── Roboto-Slab-Bold.woff2 │ │ │ │ │ ├── Roboto-Slab-Regular.woff │ │ │ │ │ ├── fontawesome-webfont.eot │ │ │ │ │ ├── fontawesome-webfont.ttf │ │ │ │ │ ├── fontawesome-webfont.woff │ │ │ │ │ ├── lato-bold-italic.woff2 │ │ │ │ │ ├── lato-normal-italic.woff │ │ │ │ │ ├── lato-normal-italic.woff2 │ │ │ │ │ ├── Roboto-Slab-Regular.woff2 │ │ │ │ │ └── fontawesome-webfont.woff2 │ │ │ │ └── badge_only.css │ │ │ ├── documentation_options.js │ │ │ ├── js │ │ │ │ ├── badge_only.js │ │ │ │ ├── html5shiv.min.js │ │ │ │ ├── html5shiv-printshiv.min.js │ │ │ │ └── theme.js │ │ │ ├── pygments.css │ │ │ ├── doctools.js │ │ │ ├── underscore.js │ │ │ └── language_data.js │ │ ├── _sources │ │ │ ├── modules.rst.txt │ │ │ ├── bigraph.evaluation.rst.txt │ │ │ ├── index.rst.txt │ │ │ ├── bigraph.rst.txt │ │ │ ├── bigraph.preprocessing.rst.txt │ │ │ └── intro.rst.txt │ │ ├── .buildinfo │ │ ├── searchindex.js │ │ ├── search.html │ │ ├── modules.html │ │ ├── py-modindex.html │ │ ├── intro.html │ │ ├── index.html │ │ ├── bigraph.evaluation.html │ │ └── genindex.html │ └── doctrees │ │ ├── index.doctree │ │ ├── intro.doctree │ │ ├── bigraph.doctree │ │ ├── modules.doctree │ │ ├── environment.pickle │ │ ├── bigraph.evaluation.doctree │ │ └── bigraph.preprocessing.doctree ├── source │ ├── modules.rst │ ├── bigraph.evaluation.rst │ ├── index.rst │ ├── bigraph.rst │ ├── bigraph.preprocessing.rst │ ├── intro.rst │ └── conf.py ├── Makefile └── make.bat ├── bigraph ├── evaluation │ └── __init__.py ├── __init__.py ├── preprocessing │ ├── __init__.py │ ├── get_adjacents.py │ ├── make_graph.py │ └── import_files.py ├── algorithms.py └── bigraph.py ├── main.py ├── pyproject.toml ├── License.txt ├── .gitignore ├── setup.py └── README.md /examples/temp.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | bluepy -------------------------------------------------------------------------------- /requirements/doc.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /requirements/extra.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /requirements/test.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.coveragerc: -------------------------------------------------------------------------------- 1 | [run] 2 | source=bigraph -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include README.md LICENSE -------------------------------------------------------------------------------- /requirements/developer.txt: -------------------------------------------------------------------------------- 1 | setuptools~=51.1.1 -------------------------------------------------------------------------------- /tests/data/target_predictions/adamic_adar_with_name.csv: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: 2 | python 3 | after_success: 4 | - bash <(curl -s https://codecov.io/bash) 5 | -------------------------------------------------------------------------------- /docs/build/html/objects.inv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/html/objects.inv -------------------------------------------------------------------------------- /docs/source/modules.rst: -------------------------------------------------------------------------------- 1 | bigraph 2 | ======= 3 | 4 | .. toctree:: 5 | :maxdepth: 4 6 | 7 | bigraph 8 | -------------------------------------------------------------------------------- /docs/build/doctrees/index.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/doctrees/index.doctree -------------------------------------------------------------------------------- /docs/build/doctrees/intro.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/doctrees/intro.doctree -------------------------------------------------------------------------------- /docs/build/html/_static/file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/html/_static/file.png -------------------------------------------------------------------------------- /docs/build/html/_static/minus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/html/_static/minus.png -------------------------------------------------------------------------------- /docs/build/html/_static/plus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/html/_static/plus.png -------------------------------------------------------------------------------- /docs/build/doctrees/bigraph.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/doctrees/bigraph.doctree -------------------------------------------------------------------------------- /docs/build/doctrees/modules.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/doctrees/modules.doctree -------------------------------------------------------------------------------- /docs/build/doctrees/environment.pickle: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/doctrees/environment.pickle -------------------------------------------------------------------------------- /docs/build/html/_sources/modules.rst.txt: -------------------------------------------------------------------------------- 1 | bigraph 2 | ======= 3 | 4 | .. toctree:: 5 | :maxdepth: 4 6 | 7 | bigraph 8 | -------------------------------------------------------------------------------- /docs/build/html/_static/fonts/Lato-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/html/_static/fonts/Lato-Bold.ttf -------------------------------------------------------------------------------- /docs/build/html/_static/fonts/Inconsolata.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/html/_static/fonts/Inconsolata.ttf -------------------------------------------------------------------------------- /docs/build/doctrees/bigraph.evaluation.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/doctrees/bigraph.evaluation.doctree -------------------------------------------------------------------------------- /docs/build/html/_static/css/fonts/lato-bold.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/html/_static/css/fonts/lato-bold.woff -------------------------------------------------------------------------------- /docs/build/html/_static/fonts/Lato-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/html/_static/fonts/Lato-Regular.ttf -------------------------------------------------------------------------------- /docs/build/html/_static/fonts/Lato/lato-bold.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/html/_static/fonts/Lato/lato-bold.eot -------------------------------------------------------------------------------- /docs/build/html/_static/fonts/Lato/lato-bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/html/_static/fonts/Lato/lato-bold.ttf -------------------------------------------------------------------------------- /docs/build/doctrees/bigraph.preprocessing.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/doctrees/bigraph.preprocessing.doctree -------------------------------------------------------------------------------- /docs/build/html/_static/css/fonts/lato-bold.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/html/_static/css/fonts/lato-bold.woff2 -------------------------------------------------------------------------------- /docs/build/html/_static/css/fonts/lato-normal.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/html/_static/css/fonts/lato-normal.woff -------------------------------------------------------------------------------- /docs/build/html/_static/fonts/Inconsolata-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/html/_static/fonts/Inconsolata-Bold.ttf -------------------------------------------------------------------------------- /docs/build/html/_static/fonts/Lato/lato-bold.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/html/_static/fonts/Lato/lato-bold.woff -------------------------------------------------------------------------------- /docs/build/html/_static/fonts/Lato/lato-bold.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/html/_static/fonts/Lato/lato-bold.woff2 -------------------------------------------------------------------------------- /docs/build/html/_static/fonts/Lato/lato-italic.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/html/_static/fonts/Lato/lato-italic.eot -------------------------------------------------------------------------------- /docs/build/html/_static/fonts/Lato/lato-italic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/html/_static/fonts/Lato/lato-italic.ttf -------------------------------------------------------------------------------- /docs/build/html/_static/fonts/RobotoSlab-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/html/_static/fonts/RobotoSlab-Bold.ttf -------------------------------------------------------------------------------- /docs/build/html/_static/css/fonts/lato-normal.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/html/_static/css/fonts/lato-normal.woff2 -------------------------------------------------------------------------------- /docs/build/html/_static/fonts/Inconsolata-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/html/_static/fonts/Inconsolata-Regular.ttf -------------------------------------------------------------------------------- /docs/build/html/_static/fonts/Lato/lato-italic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/html/_static/fonts/Lato/lato-italic.woff -------------------------------------------------------------------------------- /docs/build/html/_static/fonts/Lato/lato-italic.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/html/_static/fonts/Lato/lato-italic.woff2 -------------------------------------------------------------------------------- /docs/build/html/_static/fonts/Lato/lato-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/html/_static/fonts/Lato/lato-regular.eot -------------------------------------------------------------------------------- /docs/build/html/_static/fonts/Lato/lato-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/html/_static/fonts/Lato/lato-regular.ttf -------------------------------------------------------------------------------- /docs/build/html/_static/fonts/Lato/lato-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/html/_static/fonts/Lato/lato-regular.woff -------------------------------------------------------------------------------- /docs/build/html/_static/fonts/Lato/lato-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/html/_static/fonts/Lato/lato-regular.woff2 -------------------------------------------------------------------------------- /docs/build/html/_static/fonts/RobotoSlab-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/html/_static/fonts/RobotoSlab-Regular.ttf -------------------------------------------------------------------------------- /docs/build/html/_static/fonts/fontawesome-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/html/_static/fonts/fontawesome-webfont.eot -------------------------------------------------------------------------------- /docs/build/html/_static/fonts/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/html/_static/fonts/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /docs/build/html/_static/css/fonts/Roboto-Slab-Bold.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/html/_static/css/fonts/Roboto-Slab-Bold.woff -------------------------------------------------------------------------------- /docs/build/html/_static/css/fonts/lato-bold-italic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/html/_static/css/fonts/lato-bold-italic.woff -------------------------------------------------------------------------------- /docs/build/html/_static/fonts/Lato/lato-bolditalic.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/html/_static/fonts/Lato/lato-bolditalic.eot -------------------------------------------------------------------------------- /docs/build/html/_static/fonts/Lato/lato-bolditalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/html/_static/fonts/Lato/lato-bolditalic.ttf -------------------------------------------------------------------------------- /docs/build/html/_static/fonts/Lato/lato-bolditalic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/html/_static/fonts/Lato/lato-bolditalic.woff -------------------------------------------------------------------------------- /docs/build/html/_static/fonts/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/html/_static/fonts/fontawesome-webfont.woff -------------------------------------------------------------------------------- /docs/build/html/_static/fonts/fontawesome-webfont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/html/_static/fonts/fontawesome-webfont.woff2 -------------------------------------------------------------------------------- /docs/build/html/_static/css/fonts/Roboto-Slab-Bold.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/html/_static/css/fonts/Roboto-Slab-Bold.woff2 -------------------------------------------------------------------------------- /docs/build/html/_static/css/fonts/Roboto-Slab-Regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/html/_static/css/fonts/Roboto-Slab-Regular.woff -------------------------------------------------------------------------------- /docs/build/html/_static/css/fonts/fontawesome-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/html/_static/css/fonts/fontawesome-webfont.eot -------------------------------------------------------------------------------- /docs/build/html/_static/css/fonts/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/html/_static/css/fonts/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /docs/build/html/_static/css/fonts/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/html/_static/css/fonts/fontawesome-webfont.woff -------------------------------------------------------------------------------- /docs/build/html/_static/css/fonts/lato-bold-italic.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/html/_static/css/fonts/lato-bold-italic.woff2 -------------------------------------------------------------------------------- /docs/build/html/_static/css/fonts/lato-normal-italic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/html/_static/css/fonts/lato-normal-italic.woff -------------------------------------------------------------------------------- /docs/build/html/_static/css/fonts/lato-normal-italic.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/html/_static/css/fonts/lato-normal-italic.woff2 -------------------------------------------------------------------------------- /docs/build/html/_static/fonts/Lato/lato-bolditalic.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/html/_static/fonts/Lato/lato-bolditalic.woff2 -------------------------------------------------------------------------------- /docs/build/html/_static/css/fonts/Roboto-Slab-Regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/html/_static/css/fonts/Roboto-Slab-Regular.woff2 -------------------------------------------------------------------------------- /docs/build/html/_static/css/fonts/fontawesome-webfont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/html/_static/css/fonts/fontawesome-webfont.woff2 -------------------------------------------------------------------------------- /requirements/default.txt: -------------------------------------------------------------------------------- 1 | matplotlib>=3.2.0 2 | networkx>=2.4 3 | numpy>=1.17.4 4 | pandas>=0.25.2 5 | scikit-learn>=0.24.2 6 | 7 | tabulate>=0.8.7 8 | 9 | setuptools~=51.1.1 -------------------------------------------------------------------------------- /docs/build/html/_static/fonts/RobotoSlab/roboto-slab-v7-bold.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/html/_static/fonts/RobotoSlab/roboto-slab-v7-bold.eot -------------------------------------------------------------------------------- /docs/build/html/_static/fonts/RobotoSlab/roboto-slab-v7-bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/html/_static/fonts/RobotoSlab/roboto-slab-v7-bold.ttf -------------------------------------------------------------------------------- /docs/build/html/_static/fonts/RobotoSlab/roboto-slab-v7-bold.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/html/_static/fonts/RobotoSlab/roboto-slab-v7-bold.woff -------------------------------------------------------------------------------- /docs/build/html/_static/fonts/RobotoSlab/roboto-slab-v7-bold.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/html/_static/fonts/RobotoSlab/roboto-slab-v7-bold.woff2 -------------------------------------------------------------------------------- /docs/build/html/_static/fonts/RobotoSlab/roboto-slab-v7-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/html/_static/fonts/RobotoSlab/roboto-slab-v7-regular.eot -------------------------------------------------------------------------------- /docs/build/html/_static/fonts/RobotoSlab/roboto-slab-v7-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/html/_static/fonts/RobotoSlab/roboto-slab-v7-regular.ttf -------------------------------------------------------------------------------- /docs/build/html/_static/fonts/RobotoSlab/roboto-slab-v7-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/html/_static/fonts/RobotoSlab/roboto-slab-v7-regular.woff -------------------------------------------------------------------------------- /docs/build/html/_static/fonts/RobotoSlab/roboto-slab-v7-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bi-graph/Bigraph/HEAD/docs/build/html/_static/fonts/RobotoSlab/roboto-slab-v7-regular.woff2 -------------------------------------------------------------------------------- /docs/build/html/.buildinfo: -------------------------------------------------------------------------------- 1 | # Sphinx build info version 1 2 | # This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. 3 | config: f40406ceaf0dacf9203ef88d46b75d21 4 | tags: 645f666f9bcd5a90fca523b33c5a78b7 5 | -------------------------------------------------------------------------------- /bigraph/evaluation/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2017-2021 Bigraph developers 2 | # Author: Soran Ghadri 3 | # Contact: soran.gdr.cs@gmail.com 4 | 5 | __all__ = ["evaluation"] 6 | 7 | # import bigraph.evaluation.evaluation 8 | # from bigraph.evaluation import evaluation 9 | -------------------------------------------------------------------------------- /bigraph/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2017-2021 Bigraph developers 2 | # Author: Soran Ghadri 3 | # Contact: soran.gdr.cs@gmail.com 4 | 5 | """A package for link prediction in bipartite networks.""" 6 | from .bigraph import BiGraph 7 | 8 | __all__ = ["evaluation", "preprocessing", "BiGraph"] 9 | -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | import bigraph 2 | 3 | 4 | def main(): 5 | """ 6 | Link prediction on a bipartite network 7 | :return: 8 | """ 9 | 10 | bg = bigraph.BiGraph() 11 | 12 | bg.cn_predict() 13 | bg.jc_predict() 14 | bg.aa_predict() 15 | bg.pa_predict() 16 | 17 | 18 | if __name__ == "__main__": 19 | main() 20 | -------------------------------------------------------------------------------- /bigraph/preprocessing/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2017-2021 Bigraph developers 2 | # Author: Soran Ghadri 3 | # Contact: soran.gdr.cs@gmail.com 4 | 5 | from .get_adjacents import GetAdjacents 6 | from .import_files import ImportFiles 7 | from .make_graph import MakeGraph 8 | 9 | __all__ = [ 10 | "GetAdjacents", 11 | "ImportFiles", 12 | "MakeGraph", 13 | ] 14 | -------------------------------------------------------------------------------- /tests/unit/tests.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | import bigraph 4 | 5 | 6 | class TestAAPredict(unittest.TestCase): 7 | def test_aa_predict(self): 8 | bg = bigraph.BiGraph() 9 | output = bg.aa_predict() 10 | print(output) 11 | self.assertEqual(type(output), dict, "Not a dict") 12 | 13 | 14 | if __name__ == "__main__": 15 | unittest.main() 16 | -------------------------------------------------------------------------------- /docs/build/html/_static/documentation_options.js: -------------------------------------------------------------------------------- 1 | var DOCUMENTATION_OPTIONS = { 2 | URL_ROOT: document.getElementById("documentation_options").getAttribute('data-url_root'), 3 | VERSION: 'rc1', 4 | LANGUAGE: 'english', 5 | COLLAPSE_INDEX: false, 6 | BUILDER: 'html', 7 | FILE_SUFFIX: '.html', 8 | LINK_SUFFIX: '.html', 9 | HAS_SOURCE: true, 10 | SOURCELINK_SUFFIX: '.txt', 11 | NAVIGATION_WITH_KEYS: false 12 | }; -------------------------------------------------------------------------------- /docs/source/bigraph.evaluation.rst: -------------------------------------------------------------------------------- 1 | bigraph.evaluation package 2 | ========================== 3 | 4 | Submodules 5 | ---------- 6 | 7 | bigraph.evaluation.evaluation module 8 | ------------------------------------ 9 | 10 | .. automodule:: bigraph.evaluation.evaluation 11 | :members: 12 | :undoc-members: 13 | :show-inheritance: 14 | 15 | Module contents 16 | --------------- 17 | 18 | .. automodule:: bigraph.evaluation 19 | :members: 20 | :undoc-members: 21 | :show-inheritance: 22 | -------------------------------------------------------------------------------- /docs/build/html/_sources/bigraph.evaluation.rst.txt: -------------------------------------------------------------------------------- 1 | bigraph.evaluation package 2 | ========================== 3 | 4 | Submodules 5 | ---------- 6 | 7 | bigraph.evaluation.evaluation module 8 | ------------------------------------ 9 | 10 | .. automodule:: bigraph.evaluation.evaluation 11 | :members: 12 | :undoc-members: 13 | :show-inheritance: 14 | 15 | Module contents 16 | --------------- 17 | 18 | .. automodule:: bigraph.evaluation 19 | :members: 20 | :undoc-members: 21 | :show-inheritance: 22 | -------------------------------------------------------------------------------- /docs/source/index.rst: -------------------------------------------------------------------------------- 1 | .. d documentation master file, created by 2 | sphinx-quickstart on Fri Jul 23 06:19:34 2021. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | Welcome to d's documentation! 7 | ============================= 8 | 9 | .. toctree:: 10 | :maxdepth: 4 11 | :caption: Contents: 12 | 13 | intro 14 | bigraph 15 | 16 | 17 | Indices and tables 18 | ================== 19 | 20 | * :ref:`genindex` 21 | * :ref:`modindex` 22 | * :ref:`search` 23 | -------------------------------------------------------------------------------- /docs/build/html/_sources/index.rst.txt: -------------------------------------------------------------------------------- 1 | .. d documentation master file, created by 2 | sphinx-quickstart on Fri Jul 23 06:19:34 2021. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | Welcome to d's documentation! 7 | ============================= 8 | 9 | .. toctree:: 10 | :maxdepth: 4 11 | :caption: Contents: 12 | 13 | intro 14 | bigraph 15 | 16 | 17 | Indices and tables 18 | ================== 19 | 20 | * :ref:`genindex` 21 | * :ref:`modindex` 22 | * :ref:`search` 23 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "bigraph" 3 | version = "0.1.0" 4 | description = "" 5 | authors = ["sigma1326 " ,"soran-ghaderi "] 6 | 7 | [tool.poetry.dependencies] 8 | python = ">=3.10,<3.11" 9 | networkx = "^2.6.3" 10 | tabulate = "^0.8.9" 11 | pandas = "^1.4.1" 12 | scipy = "^1.8.1" 13 | matplotlib = "^3.5.2" 14 | scikit-learn = "^1.1.1" 15 | numpy = "^1.22.4" 16 | Pygments = "^2.12.0" 17 | 18 | [tool.poetry.dev-dependencies] 19 | 20 | [build-system] 21 | requires = ["poetry-core>=1.0.0"] 22 | build-backend = "poetry.core.masonry.api" 23 | 24 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line, and also 5 | # from the environment for the first two. 6 | SPHINXOPTS ?= 7 | SPHINXBUILD ?= sphinx-build 8 | SOURCEDIR = source 9 | BUILDDIR = build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | .PHONY: help Makefile 16 | 17 | # Catch-all target: route all unknown targets to Sphinx using the new 18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 19 | %: Makefile 20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 21 | -------------------------------------------------------------------------------- /docs/source/bigraph.rst: -------------------------------------------------------------------------------- 1 | bigraph package 2 | =============== 3 | 4 | Subpackages 5 | ----------- 6 | 7 | .. toctree:: 8 | :maxdepth: 4 9 | 10 | bigraph.evaluation 11 | bigraph.preprocessing 12 | 13 | Submodules 14 | ---------- 15 | 16 | 17 | bigraph.algorithms module 18 | ------------------------- 19 | 20 | .. automodule:: bigraph.algorithms 21 | :members: 22 | :undoc-members: 23 | :show-inheritance: 24 | 25 | bigraph.bigraph module 26 | ---------------------- 27 | 28 | .. automodule:: bigraph.bigraph 29 | :members: 30 | :undoc-members: 31 | :show-inheritance: 32 | 33 | Module contents 34 | --------------- 35 | 36 | .. automodule:: bigraph 37 | :members: 38 | :undoc-members: 39 | :show-inheritance: 40 | -------------------------------------------------------------------------------- /docs/build/html/_sources/bigraph.rst.txt: -------------------------------------------------------------------------------- 1 | bigraph package 2 | =============== 3 | 4 | Subpackages 5 | ----------- 6 | 7 | .. toctree:: 8 | :maxdepth: 4 9 | 10 | bigraph.evaluation 11 | bigraph.preprocessing 12 | bigraph.algorithms 13 | bigraph.bigraph 14 | 15 | Submodules 16 | ---------- 17 | 18 | 19 | bigraph.algorithms module 20 | ------------------------- 21 | 22 | .. automodule:: bigraph.algorithms 23 | :members: 24 | :undoc-members: 25 | :show-inheritance: 26 | 27 | bigraph.bigraph module 28 | ---------------------- 29 | 30 | .. automodule:: bigraph.bigraph 31 | :members: 32 | :undoc-members: 33 | :show-inheritance: 34 | 35 | Module contents 36 | --------------- 37 | 38 | .. automodule:: bigraph 39 | :members: 40 | :undoc-members: 41 | :show-inheritance: 42 | -------------------------------------------------------------------------------- /docs/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | pushd %~dp0 4 | 5 | REM Command file for Sphinx documentation 6 | 7 | if "%SPHINXBUILD%" == "" ( 8 | set SPHINXBUILD=sphinx-build 9 | ) 10 | set SOURCEDIR=source 11 | set BUILDDIR=build 12 | 13 | if "%1" == "" goto help 14 | 15 | %SPHINXBUILD% >NUL 2>NUL 16 | if errorlevel 9009 ( 17 | echo. 18 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 19 | echo.installed, then set the SPHINXBUILD environment variable to point 20 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 21 | echo.may add the Sphinx directory to PATH. 22 | echo. 23 | echo.If you don't have Sphinx installed, grab it from 24 | echo.http://sphinx-doc.org/ 25 | exit /b 1 26 | ) 27 | 28 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 29 | goto end 30 | 31 | :help 32 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 33 | 34 | :end 35 | popd 36 | -------------------------------------------------------------------------------- /bigraph/preprocessing/get_adjacents.py: -------------------------------------------------------------------------------- 1 | import networkx 2 | 3 | 4 | class GetAdjacents: 5 | def _get_hop_2_neighbours( 6 | self, graph: networkx.Graph, input_list: list, hop_n: int 7 | ) -> list: 8 | """ 9 | Find hop_n neighbours of each item in input_list 10 | 11 | :param graph: NetworkX graph object 12 | :param input_list: Input list 13 | :param hop_n: Hop hop_n 14 | :return: hop_n hop neighbours of the input list's items 15 | """ 16 | full_list = [] 17 | while hop_n > 0: 18 | hop_n -= 1 19 | output_list = [] 20 | for node in graph.nbunch_iter(input_list): 21 | for neighbour in graph[node]: 22 | if neighbour not in full_list: 23 | full_list.append(neighbour) 24 | output_list.append(neighbour) 25 | return output_list 26 | -------------------------------------------------------------------------------- /docs/build/html/_static/js/badge_only.js: -------------------------------------------------------------------------------- 1 | !function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=4)}({4:function(e,t,r){}}); -------------------------------------------------------------------------------- /docs/source/bigraph.preprocessing.rst: -------------------------------------------------------------------------------- 1 | bigraph.preprocessing package 2 | ============================= 3 | 4 | Submodules 5 | ---------- 6 | 7 | bigraph.preprocessing.get\_adjacents module 8 | ------------------------------------------- 9 | 10 | .. automodule:: bigraph.preprocessing.get_adjacents 11 | :members: 12 | :undoc-members: 13 | :show-inheritance: 14 | 15 | bigraph.preprocessing.import\_files module 16 | ------------------------------------------ 17 | 18 | .. automodule:: bigraph.preprocessing.import_files 19 | :members: 20 | :undoc-members: 21 | :show-inheritance: 22 | 23 | bigraph.preprocessing.make\_graph module 24 | ---------------------------------------- 25 | 26 | .. automodule:: bigraph.preprocessing.make_graph 27 | :members: 28 | :undoc-members: 29 | :show-inheritance: 30 | 31 | bigraph.preprocessing.pd\_to\_list module 32 | ----------------------------------------- 33 | 34 | .. automodule:: bigraph.preprocessing.pd_to_list 35 | :members: 36 | :undoc-members: 37 | :show-inheritance: 38 | 39 | Module contents 40 | --------------- 41 | 42 | .. automodule:: bigraph.preprocessing 43 | :members: 44 | :undoc-members: 45 | :show-inheritance: 46 | -------------------------------------------------------------------------------- /docs/build/html/_sources/bigraph.preprocessing.rst.txt: -------------------------------------------------------------------------------- 1 | bigraph.preprocessing package 2 | ============================= 3 | 4 | Submodules 5 | ---------- 6 | 7 | bigraph.preprocessing.get\_adjacents module 8 | ------------------------------------------- 9 | 10 | .. automodule:: bigraph.preprocessing.get_adjacents 11 | :members: 12 | :undoc-members: 13 | :show-inheritance: 14 | 15 | bigraph.preprocessing.import\_files module 16 | ------------------------------------------ 17 | 18 | .. automodule:: bigraph.preprocessing.import_files 19 | :members: 20 | :undoc-members: 21 | :show-inheritance: 22 | 23 | bigraph.preprocessing.make\_graph module 24 | ---------------------------------------- 25 | 26 | .. automodule:: bigraph.preprocessing.make_graph 27 | :members: 28 | :undoc-members: 29 | :show-inheritance: 30 | 31 | bigraph.preprocessing.pd\_to\_list module 32 | ----------------------------------------- 33 | 34 | .. automodule:: bigraph.preprocessing.pd_to_list 35 | :members: 36 | :undoc-members: 37 | :show-inheritance: 38 | 39 | Module contents 40 | --------------- 41 | 42 | .. automodule:: bigraph.preprocessing 43 | :members: 44 | :undoc-members: 45 | :show-inheritance: 46 | -------------------------------------------------------------------------------- /tests/data/inputs/id_labels.csv: -------------------------------------------------------------------------------- 1 | ID,Label 2 | 0,left_node_0 3 | 1,left_node_1 4 | 2,left_node_2 5 | 3,left_node_3 6 | 4,left_node_4 7 | 5,left_node_5 8 | 6,left_node_6 9 | 7,left_node_7 10 | 8,left_node_8 11 | 9,left_node_9 12 | 10,left_node_10 13 | 11,left_node_11 14 | 12,left_node_12 15 | 13,left_node_13 16 | 14,left_node_14 17 | 15,left_node_15 18 | 16,left_node_16 19 | 17,left_node_17 20 | 18,left_node_18 21 | 19,left_node_19 22 | 20,left_node_20 23 | 21,left_node_21 24 | 22,left_node_22 25 | 23,left_node_23 26 | 24,left_node_24 27 | 25,left_node_25 28 | 26,left_node_26 29 | 27,left_node_27 30 | 28,left_node_28 31 | 29,left_node_29 32 | 30,left_node_30 33 | 31,left_node_31 34 | 32,left_node_32 35 | 33,left_node_33 36 | 34,left_node_34 37 | 35,left_node_35 38 | 36,left_node_36 39 | 37,left_node_37 40 | 38,left_node_38 41 | 100,right_node_0 42 | 101,right_node_1 43 | 102,right_node_2 44 | 103,right_node_3 45 | 104,right_node_4 46 | 105,right_node_5 47 | 106,right_node_6 48 | 107,right_node_7 49 | 108,right_node_8 50 | 109,right_node_9 51 | 110,right_node_10 52 | 111,right_node_11 53 | 112,right_node_12 54 | 113,right_node_13 55 | 114,right_node_14 56 | 115,right_node_15 57 | 116,right_node_16 58 | 117,right_node_17 59 | 118,right_node_18 60 | 119,right_node_19 61 | 120,right_node_20 62 | 121,right_node_21 63 | 122,right_node_22 64 | 123,right_node_23 65 | 124,right_node_24 66 | 125,right_node_25 67 | 126,right_node_26 68 | -------------------------------------------------------------------------------- /docs/source/intro.rst: -------------------------------------------------------------------------------- 1 | Introduction 2 | ============ 3 | 4 | ``bigraph`` is a high-level OO Python package which aims to provide an easy and intuitive way of interacting with bipartite networks. In essence, this package is an extension of the ``NetworkX`` package (see `here `_) 5 | 6 | The aim here was to define an easy-to-use package which would allow developers to perform ``link pridiction``, ``evaluation``, and ``visualization`` of the results. 7 | 8 | The current implementation has been developed and tested in Python 3.6+, but should work with Python 2.7+ (maybe with minor modifications in terms of printing and error handling) and most Debian based OSs. 9 | 10 | Motivation 11 | ********** 12 | 13 | As a developer in the field of machine learning, I found it pretty hard to identify a Python package which would enable one to perform link pridiction algorithms over bipartite networks. 14 | 15 | This package is intended to provide a quick, as well as (hopefully) easy to undestand, way of dealing-with-bipartite-networks algorithm up and running, for all those out there, who, like myself, are hands-on learners and are eager to get their hands dirty from early on. 16 | 17 | Limitations 18 | *********** 19 | 20 | - Algorithms are quite a few, and thus have to be piled with new ones. 21 | - Evaluations used here are techniques used for unsupervised methods, however they may have to be modified. 22 | - There are more limitations for sure if you happened to encounter any issue, you are welcomed to make contributions or open and issue on github. -------------------------------------------------------------------------------- /docs/build/html/_sources/intro.rst.txt: -------------------------------------------------------------------------------- 1 | Introduction 2 | ============ 3 | 4 | ``bigraph`` is a high-level OO Python package which aims to provide an easy and intuitive way of interacting with bipartite networks. In essence, this package is an extension of the ``NetworkX`` package (see `here `_) 5 | 6 | The aim here was to define an easy-to-use package which would allow developers to perform ``link pridiction``, ``evaluation``, and ``visualization`` of the results. 7 | 8 | The current implementation has been developed and tested in Python 3.6+, but should work with Python 2.7+ (maybe with minor modifications in terms of printing and error handling) and most Debian based OSs. 9 | 10 | Motivation 11 | ********** 12 | 13 | As a developer in the field of machine learning, I found it pretty hard to identify a Python package which would enable one to perform link pridiction algorithms over bipartite networks. 14 | 15 | This package is intended to provide a quick, as well as (hopefully) easy to undestand, way of dealing-with-bipartite-networks algorithm up and running, for all those out there, who, like myself, are hands-on learners and are eager to get their hands dirty from early on. 16 | 17 | Limitations 18 | *********** 19 | 20 | - Algorithms are quite a few, and thus have to be piled with new ones. 21 | - Evaluations used here are techniques used for unsupervised methods, however they may have to be modified. 22 | - There are more limitations for sure if you happened to encounter any issue, you are welcomed to make contributions or open and issue on github. -------------------------------------------------------------------------------- /bigraph/preprocessing/make_graph.py: -------------------------------------------------------------------------------- 1 | import networkx as nx 2 | 3 | 4 | class MakeGraph: 5 | def make_graph( 6 | self, 7 | dataframe: dict, 8 | left_bipartite: str = "left_side", 9 | right_bipartite: str = "right_side", 10 | ): 11 | """ 12 | Make a graph based on the input dataframe 13 | 14 | :param left_bipartite: Left part of the graph 15 | :param right_bipartite: Right part of the graph 16 | :param dataframe: Bipartite graph dataframe 17 | :return: Generated networkx graph 18 | """ 19 | node_list = [] 20 | graph = nx.Graph() 21 | graph.add_nodes_from(dataframe[left_bipartite], bipartite=0) 22 | graph.add_nodes_from(dataframe[right_bipartite], bipartite=1) 23 | for node in dataframe.iterrows(): 24 | node_list.append(node[1][0]) 25 | node_list.append(node[1][1]) 26 | 27 | graph.add_edges_from(self._add_to_list(dataframe)) 28 | isolates = nx.isolates(graph) 29 | # TODO: make following line a choice to be able to remove isolates or not 30 | 31 | # graph.remove_nodes_from(isolates) 32 | print("Graph made successfully", "\n") 33 | return graph 34 | 35 | def _add_to_list(self, dataframe: dict) -> list: 36 | """ 37 | Generate link tuples and append them to a list 38 | 39 | :param dataframe: Dataframe containing links 40 | :return: Edge list 41 | """ 42 | edge_list = [] 43 | for edge_row in dataframe.iterrows(): 44 | tuples = edge_row[1][0], edge_row[1][1] 45 | edge_list.append(tuples) 46 | return edge_list 47 | -------------------------------------------------------------------------------- /License.txt: -------------------------------------------------------------------------------- 1 | License 2 | ======= 3 | 4 | BiGraph is distributed with the 3-clause BSD license. 5 | 6 | :: 7 | 8 | Copyright (C) 2019-2021, BiGraph Developers 9 | Soran Ghadri 10 | Taleb Zarhesh 11 | All rights reserved. 12 | 13 | Redistribution and use in source and binary forms, with or without 14 | modification, are permitted provided that the following conditions are 15 | met: 16 | 17 | * Redistributions of source code must retain the above copyright 18 | notice, this list of conditions and the following disclaimer. 19 | 20 | * Redistributions in binary form must reproduce the above 21 | copyright notice, this list of conditions and the following 22 | disclaimer in the documentation and/or other materials provided 23 | with the distribution. 24 | 25 | * Neither the name of the BiGraph Developers nor the names of its 26 | contributors may be used to endorse or promote products derived 27 | from this software without specific prior written permission. 28 | 29 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 30 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 31 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 32 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 33 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 34 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 35 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 36 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 37 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 38 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 39 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | /.idea/ 6 | 7 | # C extensions 8 | *.so 9 | 10 | # Distribution / packaging 11 | .Python 12 | build/ 13 | develop-eggs/ 14 | dist/ 15 | downloads/ 16 | eggs/ 17 | .eggs/ 18 | lib/ 19 | lib64/ 20 | parts/ 21 | sdist/ 22 | var/ 23 | wheels/ 24 | pip-wheel-metadata/ 25 | share/python-wheels/ 26 | *.egg-info/ 27 | .installed.cfg 28 | *.egg 29 | MANIFEST 30 | .idea 31 | 32 | # PyInstaller 33 | # Usually these files are written by a python script from a template 34 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 35 | *.manifest 36 | *.spec 37 | 38 | # Installer logs 39 | pip-log.txt 40 | pip-delete-this-directory.txt 41 | 42 | # Unit test / coverage reports 43 | htmlcov/ 44 | .tox/ 45 | .nox/ 46 | .coverage 47 | .coverage.* 48 | .cache 49 | nosetests.xml 50 | coverage.xml 51 | *.cover 52 | *.py,cover 53 | .hypothesis/ 54 | .pytest_cache/ 55 | 56 | # Translations 57 | *.mo 58 | *.pot 59 | 60 | # Django stuff: 61 | *.log 62 | local_settings.py 63 | db.sqlite3 64 | db.sqlite3-journal 65 | 66 | # Flask stuff: 67 | instance/ 68 | .webassets-cache 69 | 70 | # Scrapy stuff: 71 | .scrapy 72 | 73 | # Sphinx documentation 74 | #docs/_build/ 75 | 76 | # PyBuilder 77 | target/ 78 | 79 | # Jupyter Notebook 80 | .ipynb_checkpoints 81 | 82 | # IPython 83 | profile_default/ 84 | ipython_config.py 85 | 86 | # pyenv 87 | .python-version 88 | 89 | # pipenv 90 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 91 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 92 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 93 | # install all needed dependencies. 94 | #Pipfile.lock 95 | 96 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 97 | __pypackages__/ 98 | 99 | # Celery stuff 100 | celerybeat-schedule 101 | celerybeat.pid 102 | 103 | # SageMath parsed files 104 | *.sage.py 105 | 106 | # Environments 107 | .env 108 | .venv 109 | env/ 110 | venv/ 111 | ENV/ 112 | env.bak/ 113 | venv.bak/ 114 | 115 | # Spyder project settings 116 | .spyderproject 117 | .spyproject 118 | 119 | # Rope project settings 120 | .ropeproject 121 | 122 | # mkdocs documentation 123 | /site 124 | 125 | # mypy 126 | .mypy_cache/ 127 | .dmypy.json 128 | dmypy.json 129 | 130 | # Pyre type checker 131 | .pyre/ 132 | /predictions/ 133 | /inputs/ 134 | 135 | poetry.lock 136 | -------------------------------------------------------------------------------- /docs/build/html/_static/js/html5shiv.min.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @preserve HTML5 Shiv 3.7.3 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed 3 | */ 4 | !function(a,b){function c(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x",d.insertBefore(c.lastChild,d.firstChild)}function d(){var a=t.elements;return"string"==typeof a?a.split(" "):a}function e(a,b){var c=t.elements;"string"!=typeof c&&(c=c.join(" ")),"string"!=typeof a&&(a=a.join(" ")),t.elements=c+" "+a,j(b)}function f(a){var b=s[a[q]];return b||(b={},r++,a[q]=r,s[r]=b),b}function g(a,c,d){if(c||(c=b),l)return c.createElement(a);d||(d=f(c));var e;return e=d.cache[a]?d.cache[a].cloneNode():p.test(a)?(d.cache[a]=d.createElem(a)).cloneNode():d.createElem(a),!e.canHaveChildren||o.test(a)||e.tagUrn?e:d.frag.appendChild(e)}function h(a,c){if(a||(a=b),l)return a.createDocumentFragment();c=c||f(a);for(var e=c.frag.cloneNode(),g=0,h=d(),i=h.length;i>g;g++)e.createElement(h[g]);return e}function i(a,b){b.cache||(b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag()),a.createElement=function(c){return t.shivMethods?g(c,a,b):b.createElem(c)},a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+d().join().replace(/[\w\-:]+/g,function(a){return b.createElem(a),b.frag.createElement(a),'c("'+a+'")'})+");return n}")(t,b.frag)}function j(a){a||(a=b);var d=f(a);return!t.shivCSS||k||d.hasCSS||(d.hasCSS=!!c(a,"article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}template{display:none}")),l||i(a,d),a}var k,l,m="3.7.3-pre",n=a.html5||{},o=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,p=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,q="_html5shiv",r=0,s={};!function(){try{var a=b.createElement("a");a.innerHTML="",k="hidden"in a,l=1==a.childNodes.length||function(){b.createElement("a");var a=b.createDocumentFragment();return"undefined"==typeof a.cloneNode||"undefined"==typeof a.createDocumentFragment||"undefined"==typeof a.createElement}()}catch(c){k=!0,l=!0}}();var t={elements:n.elements||"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output picture progress section summary template time video",version:m,shivCSS:n.shivCSS!==!1,supportsUnknownElements:l,shivMethods:n.shivMethods!==!1,type:"default",shivDocument:j,createElement:g,createDocumentFragment:h,addElements:e};a.html5=t,j(b),"object"==typeof module&&module.exports&&(module.exports=t)}("undefined"!=typeof window?window:this,document); -------------------------------------------------------------------------------- /bigraph/algorithms.py: -------------------------------------------------------------------------------- 1 | import math 2 | 3 | 4 | class Algorithms: 5 | @staticmethod 6 | def adamic_adar(set_one: list, set_two: list, graph) -> float: 7 | """ 8 | Calculate Adamic Adar score for input lists 9 | 10 | :param set_one: A list of graph nodes -> part one 11 | :param set_two: A list of graph nodes -> part two 12 | :param graph: NetworkX bipartite graph 13 | :return: Adamic Adar score 14 | """ 15 | intersection = set(set_one) & set(set_two) 16 | sum = 0 17 | for node in intersection: 18 | # Get neighbors count 19 | degree = set(graph[node]).__len__() 20 | if degree > 1: 21 | sum += (math.log(degree)) ** -1 22 | else: 23 | sum += 0 24 | return sum 25 | 26 | @staticmethod 27 | def common_neighbors(set_one: list, set_two: list) -> int: 28 | """ 29 | Calculate Common neighbors score for input lists 30 | 31 | :param set_one: A list of graph nodes -> part one 32 | :param set_two: A list of graph nodes -> part two 33 | :return: Common neighbours score 34 | """ 35 | return len(set(set_one) & set(set_two)) 36 | 37 | @staticmethod 38 | def preferential_attachment(set_one: list, set_two: list) -> int: 39 | """ 40 | Calculate Preferential attachment score for input lists 41 | 42 | :param set_one: A list of graph nodes -> part one 43 | :param set_two: A list of graph nodes -> part two 44 | :return: Preferential attachment score 45 | """ 46 | return len(set(set_one)) * len(set(set_two)) 47 | 48 | @staticmethod 49 | def jaccard(set_one: list, set_two: list) -> float: 50 | """ 51 | Calculate Jaccard score for input lists 52 | 53 | :param set_one: A list of graph nodes -> part one 54 | :param set_two: A list of graph nodes -> part two 55 | :return: Jaccard score 56 | """ 57 | intersection = len(set(set_one) & set(set_two)) 58 | union = len(set(set_one) | set(set_two)) 59 | return float(intersection) / float(union) 60 | 61 | @staticmethod 62 | def katz_similarity(node_i: int, node_j: int, graph) -> float: 63 | """ 64 | Calculate Katz score for input nodes 65 | 66 | :param node_i: Starting node 67 | :param node_j: Destination node 68 | :param graph: NetworkX bipartite graph 69 | :return: Katz similarity score 70 | """ 71 | length = 1 72 | neighbors = set(graph[node_i]) 73 | score = 0 74 | max_length = 2 75 | beta = 0.1 76 | 77 | while length <= max_length: 78 | number_of_paths = neighbors.count(node_j) 79 | if number_of_paths > 0: 80 | score += (beta**length) * number_of_paths 81 | 82 | neighbours_for_next_loop = [] 83 | for k in neighbors: 84 | neighbours_for_next_loop += set(graph[k]) 85 | neighbors = neighbours_for_next_loop 86 | length += 1 87 | return score 88 | -------------------------------------------------------------------------------- /docs/build/html/_static/css/badge_only.css: -------------------------------------------------------------------------------- 1 | .fa:before{-webkit-font-smoothing:antialiased}.clearfix{*zoom:1}.clearfix:after,.clearfix:before{display:table;content:""}.clearfix:after{clear:both}@font-face{font-family:FontAwesome;font-style:normal;font-weight:400;src:url(fonts/fontawesome-webfont.eot?674f50d287a8c48dc19ba404d20fe713?#iefix) format("embedded-opentype"),url(fonts/fontawesome-webfont.woff2?af7ae505a9eed503f8b8e6982036873e) format("woff2"),url(fonts/fontawesome-webfont.woff?fee66e712a8a08eef5805a46892932ad) format("woff"),url(fonts/fontawesome-webfont.ttf?b06871f281fee6b241d60582ae9369b9) format("truetype"),url(fonts/fontawesome-webfont.svg?912ec66d7572ff821749319396470bde#FontAwesome) format("svg")}.fa:before{font-family:FontAwesome;font-style:normal;font-weight:400;line-height:1}.fa:before,a .fa{text-decoration:inherit}.fa:before,a .fa,li .fa{display:inline-block}li .fa-large:before{width:1.875em}ul.fas{list-style-type:none;margin-left:2em;text-indent:-.8em}ul.fas li .fa{width:.8em}ul.fas li .fa-large:before{vertical-align:baseline}.fa-book:before,.icon-book:before{content:"\f02d"}.fa-caret-down:before,.icon-caret-down:before{content:"\f0d7"}.fa-caret-up:before,.icon-caret-up:before{content:"\f0d8"}.fa-caret-left:before,.icon-caret-left:before{content:"\f0d9"}.fa-caret-right:before,.icon-caret-right:before{content:"\f0da"}.rst-versions{position:fixed;bottom:0;left:0;width:300px;color:#fcfcfc;background:#1f1d1d;font-family:Lato,proxima-nova,Helvetica Neue,Arial,sans-serif;z-index:400}.rst-versions a{color:#2980b9;text-decoration:none}.rst-versions .rst-badge-small{display:none}.rst-versions .rst-current-version{padding:12px;background-color:#272525;display:block;text-align:right;font-size:90%;cursor:pointer;color:#27ae60}.rst-versions .rst-current-version:after{clear:both;content:"";display:block}.rst-versions .rst-current-version .fa{color:#fcfcfc}.rst-versions .rst-current-version .fa-book,.rst-versions .rst-current-version .icon-book{float:left}.rst-versions .rst-current-version.rst-out-of-date{background-color:#e74c3c;color:#fff}.rst-versions .rst-current-version.rst-active-old-version{background-color:#f1c40f;color:#000}.rst-versions.shift-up{height:auto;max-height:100%;overflow-y:scroll}.rst-versions.shift-up .rst-other-versions{display:block}.rst-versions .rst-other-versions{font-size:90%;padding:12px;color:grey;display:none}.rst-versions .rst-other-versions hr{display:block;height:1px;border:0;margin:20px 0;padding:0;border-top:1px solid #413d3d}.rst-versions .rst-other-versions dd{display:inline-block;margin:0}.rst-versions .rst-other-versions dd a{display:inline-block;padding:6px;color:#fcfcfc}.rst-versions.rst-badge{width:auto;bottom:20px;right:20px;left:auto;border:none;max-width:300px;max-height:90%}.rst-versions.rst-badge .fa-book,.rst-versions.rst-badge .icon-book{float:none;line-height:30px}.rst-versions.rst-badge.shift-up .rst-current-version{text-align:right}.rst-versions.rst-badge.shift-up .rst-current-version .fa-book,.rst-versions.rst-badge.shift-up .rst-current-version .icon-book{float:left}.rst-versions.rst-badge>.rst-current-version{width:auto;height:30px;line-height:30px;padding:0 6px;display:block;text-align:center}@media screen and (max-width:768px){.rst-versions{width:85%;display:none}.rst-versions.shift{display:block}} -------------------------------------------------------------------------------- /docs/source/conf.py: -------------------------------------------------------------------------------- 1 | # Configuration file for the Sphinx documentation builder. 2 | # 3 | # This file only contains a selection of the most common options. For a full 4 | # list see the documentation: 5 | # https://www.sphinx-doc.org/en/master/usage/configuration.html 6 | 7 | # -- Path setup -------------------------------------------------------------- 8 | 9 | # If extensions (or modules to document with autodoc) are in another directory, 10 | # add these directories to sys.path here. If the directory is relative to the 11 | # documentation root, use os.path.abspath to make it absolute, like shown here. 12 | # 13 | import os 14 | import sys 15 | 16 | sys.path.insert(0, os.path.abspath("../../")) 17 | from datetime import datetime 18 | from pygments.styles import get_style_by_name 19 | 20 | 21 | # -- Project information ----------------------------------------------------- 22 | 23 | project = "Bigraph" 24 | copyright = f"2019-{datetime.now().year}, Soran Ghadri" 25 | author = "Soran Ghadri" 26 | 27 | style = get_style_by_name("friendly") 28 | style.background_color = "#f3f2f1" 29 | 30 | # The full version, including alpha/beta/rc tags 31 | release = "rc1" 32 | 33 | 34 | # -- General configuration --------------------------------------------------- 35 | 36 | # Add any Sphinx extension module names here, as strings. They can be 37 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom 38 | # ones. 39 | extensions = [ 40 | "sphinx_rtd_theme", 41 | "sphinx.ext.autodoc", 42 | "sphinx.ext.autosummary", 43 | "sphinx.ext.napoleon", 44 | "sphinx.ext.mathjax", 45 | ] 46 | 47 | # Add any paths that contain templates here, relative to this directory. 48 | templates_path = ["_templates"] 49 | 50 | napoleon_use_rtype = False 51 | 52 | napoleon_include_init_with_doc = True 53 | napoleon_google_docstring = True 54 | napoleon_use_param = True 55 | napoleon_use_ivar = True 56 | 57 | pygments_style = "friendly" 58 | 59 | 60 | # The language for content autogenerated by Sphinx. Refer to documentation 61 | # for a list of supported languages. 62 | # 63 | # This is also used if you do content translation via gettext catalogs. 64 | # Usually you set "language" from the command line for these cases. 65 | language = "english" 66 | 67 | # List of patterns, relative to source directory, that match files and 68 | # directories to ignore when looking for source files. 69 | # This pattern also affects html_static_path and html_extra_path. 70 | exclude_patterns = [] 71 | 72 | 73 | # -- Options for HTML output ------------------------------------------------- 74 | 75 | # The theme to use for HTML and HTML Help pages. See the documentation for 76 | # a list of builtin themes. 77 | # 78 | # html_theme = 'alabaster' 79 | html_theme = "sphinx_rtd_theme" 80 | html_title = "Bigraph Documentation" 81 | html_show_sourcelink = False 82 | html_baseurl = "https://github.com/bi-graph/bigraph" 83 | # html_show_copyright = False 84 | # Add any paths that contain custom static files (such as style sheets) here, 85 | # relative to this directory. They are copied after the builtin static files, 86 | # so a file named "default.css" will overwrite the builtin "default.css". 87 | html_static_path = ["_static"] 88 | 89 | html_theme_options = { 90 | "prev_next_buttons_location": "both", 91 | "style_nav_header_background": "#F5A603", 92 | "navigation_depth": 4, 93 | "collapse_navigation": True, 94 | "sticky_navigation": False, 95 | "logo_only": True, 96 | "display_version": True, 97 | "style_external_links": True, 98 | "titles_only": True, 99 | } 100 | 101 | napoleon_use_param = False 102 | -------------------------------------------------------------------------------- /docs/build/html/_static/js/html5shiv-printshiv.min.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @preserve HTML5 Shiv 3.7.3-pre | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed 3 | */ 4 | !function(a,b){function c(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x",d.insertBefore(c.lastChild,d.firstChild)}function d(){var a=y.elements;return"string"==typeof a?a.split(" "):a}function e(a,b){var c=y.elements;"string"!=typeof c&&(c=c.join(" ")),"string"!=typeof a&&(a=a.join(" ")),y.elements=c+" "+a,j(b)}function f(a){var b=x[a[v]];return b||(b={},w++,a[v]=w,x[w]=b),b}function g(a,c,d){if(c||(c=b),q)return c.createElement(a);d||(d=f(c));var e;return e=d.cache[a]?d.cache[a].cloneNode():u.test(a)?(d.cache[a]=d.createElem(a)).cloneNode():d.createElem(a),!e.canHaveChildren||t.test(a)||e.tagUrn?e:d.frag.appendChild(e)}function h(a,c){if(a||(a=b),q)return a.createDocumentFragment();c=c||f(a);for(var e=c.frag.cloneNode(),g=0,h=d(),i=h.length;i>g;g++)e.createElement(h[g]);return e}function i(a,b){b.cache||(b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag()),a.createElement=function(c){return y.shivMethods?g(c,a,b):b.createElem(c)},a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+d().join().replace(/[\w\-:]+/g,function(a){return b.createElem(a),b.frag.createElement(a),'c("'+a+'")'})+");return n}")(y,b.frag)}function j(a){a||(a=b);var d=f(a);return!y.shivCSS||p||d.hasCSS||(d.hasCSS=!!c(a,"article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}template{display:none}")),q||i(a,d),a}function k(a){for(var b,c=a.getElementsByTagName("*"),e=c.length,f=RegExp("^(?:"+d().join("|")+")$","i"),g=[];e--;)b=c[e],f.test(b.nodeName)&&g.push(b.applyElement(l(b)));return g}function l(a){for(var b,c=a.attributes,d=c.length,e=a.ownerDocument.createElement(A+":"+a.nodeName);d--;)b=c[d],b.specified&&e.setAttribute(b.nodeName,b.nodeValue);return e.style.cssText=a.style.cssText,e}function m(a){for(var b,c=a.split("{"),e=c.length,f=RegExp("(^|[\\s,>+~])("+d().join("|")+")(?=[[\\s,>+~#.:]|$)","gi"),g="$1"+A+"\\:$2";e--;)b=c[e]=c[e].split("}"),b[b.length-1]=b[b.length-1].replace(f,g),c[e]=b.join("}");return c.join("{")}function n(a){for(var b=a.length;b--;)a[b].removeNode()}function o(a){function b(){clearTimeout(g._removeSheetTimer),d&&d.removeNode(!0),d=null}var d,e,g=f(a),h=a.namespaces,i=a.parentWindow;return!B||a.printShived?a:("undefined"==typeof h[A]&&h.add(A),i.attachEvent("onbeforeprint",function(){b();for(var f,g,h,i=a.styleSheets,j=[],l=i.length,n=Array(l);l--;)n[l]=i[l];for(;h=n.pop();)if(!h.disabled&&z.test(h.media)){try{f=h.imports,g=f.length}catch(o){g=0}for(l=0;g>l;l++)n.push(f[l]);try{j.push(h.cssText)}catch(o){}}j=m(j.reverse().join("")),e=k(a),d=c(a,j)}),i.attachEvent("onafterprint",function(){n(e),clearTimeout(g._removeSheetTimer),g._removeSheetTimer=setTimeout(b,500)}),a.printShived=!0,a)}var p,q,r="3.7.3",s=a.html5||{},t=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,u=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,v="_html5shiv",w=0,x={};!function(){try{var a=b.createElement("a");a.innerHTML="",p="hidden"in a,q=1==a.childNodes.length||function(){b.createElement("a");var a=b.createDocumentFragment();return"undefined"==typeof a.cloneNode||"undefined"==typeof a.createDocumentFragment||"undefined"==typeof a.createElement}()}catch(c){p=!0,q=!0}}();var y={elements:s.elements||"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output picture progress section summary template time video",version:r,shivCSS:s.shivCSS!==!1,supportsUnknownElements:q,shivMethods:s.shivMethods!==!1,type:"default",shivDocument:j,createElement:g,createDocumentFragment:h,addElements:e};a.html5=y,j(b);var z=/^$|\b(?:all|print)\b/,A="html5shiv",B=!q&&function(){var c=b.documentElement;return!("undefined"==typeof b.namespaces||"undefined"==typeof b.parentWindow||"undefined"==typeof c.applyElement||"undefined"==typeof c.removeNode||"undefined"==typeof a.attachEvent)}();y.type+=" print",y.shivPrint=o,o(b),"object"==typeof module&&module.exports&&(module.exports=y)}("undefined"!=typeof window?window:this,document); -------------------------------------------------------------------------------- /docs/build/html/searchindex.js: -------------------------------------------------------------------------------- 1 | Search.setIndex({docnames:["bigraph","bigraph.evaluation","bigraph.preprocessing","index","intro","modules"],envversion:{"sphinx.domains.c":2,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":3,"sphinx.domains.index":1,"sphinx.domains.javascript":2,"sphinx.domains.math":2,"sphinx.domains.python":2,"sphinx.domains.rst":2,"sphinx.domains.std":1,sphinx:56},filenames:["bigraph.rst","bigraph.evaluation.rst","bigraph.preprocessing.rst","index.rst","intro.rst","modules.rst"],objects:{"":{bigraph:[0,0,0,"-"]},"bigraph.algorithms":{adamic_adar:[0,1,1,""],common_neighbors:[0,1,1,""],jaccard:[0,1,1,""],katz_similarity:[0,1,1,""],preferential_attachment:[0,1,1,""]},"bigraph.bigraph":{aa_predict:[0,1,1,""],cn_predict:[0,1,1,""],jc_predict:[0,1,1,""],katz_predict:[0,1,1,""],pa_predict:[0,1,1,""]},"bigraph.evaluation":{evaluation:[1,0,0,"-"]},"bigraph.evaluation.evaluation":{evaluate:[1,1,1,""],plot_ROC:[1,1,1,""]},"bigraph.preprocessing":{get_adjacents:[2,0,0,"-"],import_files:[2,0,0,"-"],make_graph:[2,0,0,"-"],pd_to_list:[2,0,0,"-"]},"bigraph.preprocessing.get_adjacents":{get_hop_2_neighbours:[2,1,1,""]},"bigraph.preprocessing.import_files":{check_input_files:[2,1,1,""],generate_random_graph_edges:[2,1,1,""],generate_random_graph_labels:[2,1,1,""],import_files:[2,1,1,""]},"bigraph.preprocessing.make_graph":{make_graph:[2,1,1,""]},"bigraph.preprocessing.pd_to_list":{add_to_list:[2,1,1,""]},bigraph:{algorithms:[0,0,0,"-"],bigraph:[0,0,0,"-"],evaluation:[1,0,0,"-"],preprocessing:[2,0,0,"-"]}},objnames:{"0":["py","module","Python module"],"1":["py","function","Python function"]},objtypes:{"0":"py:module","1":"py:function"},terms:{"float":0,"function":2,"import":2,"int":[0,1,2],"new":4,"return":[0,1,2],"true":[1,2],The:4,There:4,aa_predict:0,adam:0,adamic_adar:0,adar:0,add_to_list:2,aim:4,algorithm:[1,3,4,5],all:[0,1,4],allow:4,ani:[2,4],append:2,arg:2,arrai:0,attach:0,base:[2,4],been:4,between:0,bigraph:[3,4],bipartit:[0,1,2,4],bool:2,boundari:2,calcul:[0,1],check:2,check_input_fil:2,cn_predict:0,common:0,common_neighbor:0,comput:0,contain:[0,2],content:[3,5],contribut:4,csv:2,current:4,curv:1,data:2,datafram:2,deal:4,debian:4,defin:4,destin:0,develop:4,df_node:0,dict:[0,2],dictionari:0,dirti:4,dissimilar:0,distanc:0,distinct:2,each:2,eager:4,earli:4,easi:4,edg:2,edge_csv:2,enabl:4,encount:4,entiti:2,error:4,essenc:4,evalu:[0,3,4,5],extens:4,fals:1,few:4,field:4,file:2,find:2,finish:2,fold:1,found:4,fpr:1,fpr_algo:1,from:[2,4],gener:2,generate_random_graph_edg:2,generate_random_graph_label:2,get:4,get_adjac:[0,3,5],get_hop_2_neighbour:2,github:4,graph:[0,1,2],hand:4,handl:4,happen:4,hard:4,has:4,have:4,here:4,high:4,hop:2,hop_n:2,hopefulli:4,howev:4,id_label:2,identifi:4,implement:4,import_fil:[0,3,5],index:3,input:[0,2],input_list:2,intend:4,interact:4,interfac:1,introduct:3,intuit:4,issu:4,item:2,jaccard:0,jc_predict:0,katz:0,katz_predict:0,katz_similar:0,kfold:1,kwarg:2,label:2,label_id:2,learn:4,learner:4,left:2,left_bipartit:2,left_el:0,left_nodes_count:2,left_sid:2,level:4,like:4,limit:3,line:2,link:[2,4],list:[0,1,2],machin:4,mai:4,make:[2,4],make_graph:[0,3,5],mayb:4,met:1,method:[1,4],metric:1,minor:4,modif:4,modifi:4,modul:[3,5],more:4,most:4,motiv:3,myself:4,name:1,needham:0,neighbor:0,neighbour:[0,2],neighbour_matrix:2,network:4,networkx:[0,1,2,4],node:[0,2],node_i:0,node_j:0,node_nam:2,number:[1,2],object:[0,1,2],one:[0,4],ones:4,open:4,oss:4,out:4,over:4,overall_auc:1,overall_precis:1,pa_predict:0,packag:[3,4,5],page:3,pair:0,paramet:[0,1,2],part:[0,2],path:2,pd_to_list:[0,3,5],perform:4,pile:4,plot:1,plot_roc:1,posit:1,preferenti:0,preferential_attach:0,preprocess:[0,3,5],pretti:4,pridict:4,print:4,provid:4,python:4,quick:4,quit:4,random:2,randomli:2,rate:1,respect:2,result:4,right:2,right_bipartit:2,right_el:0,right_nodes_count:2,right_sid:2,roc:1,run:4,score:0,search:3,see:4,sep:2,separ:2,set_on:0,set_two:0,should:4,side:2,similar:0,stand:2,start:0,str:[1,2],submodul:[3,5],subpackag:[3,5],success:[1,2],successfulli:2,sure:4,techniqu:4,term:4,test:4,thei:4,them:2,thi:4,those:4,thu:4,tpr:1,tpr_algo:1,tupl:2,two:0,type:1,undestand:4,unsupervis:4,use:4,used:[1,4],vector:0,visual:4,wai:4,weight:2,welcom:4,well:4,which:[2,4],who:4,work:4,would:4,write:2,you:4},titles:["bigraph package","bigraph.evaluation package","bigraph.preprocessing package","Welcome to d's documentation!","Introduction","bigraph"],titleterms:{algorithm:0,bigraph:[0,1,2,5],content:[0,1,2],document:3,evalu:1,get_adjac:2,import_fil:2,indic:3,introduct:4,limit:4,make_graph:2,modul:[0,1,2],motiv:4,packag:[0,1,2],pd_to_list:2,preprocess:2,submodul:[0,1,2],subpackag:0,tabl:3,welcom:3}}) -------------------------------------------------------------------------------- /docs/build/html/_static/js/theme.js: -------------------------------------------------------------------------------- 1 | !function(n){var e={};function t(i){if(e[i])return e[i].exports;var o=e[i]={i:i,l:!1,exports:{}};return n[i].call(o.exports,o,o.exports,t),o.l=!0,o.exports}t.m=n,t.c=e,t.d=function(n,e,i){t.o(n,e)||Object.defineProperty(n,e,{enumerable:!0,get:i})},t.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},t.t=function(n,e){if(1&e&&(n=t(n)),8&e)return n;if(4&e&&"object"==typeof n&&n&&n.__esModule)return n;var i=Object.create(null);if(t.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:n}),2&e&&"string"!=typeof n)for(var o in n)t.d(i,o,function(e){return n[e]}.bind(null,o));return i},t.n=function(n){var e=n&&n.__esModule?function(){return n.default}:function(){return n};return t.d(e,"a",e),e},t.o=function(n,e){return Object.prototype.hasOwnProperty.call(n,e)},t.p="",t(t.s=0)}([function(n,e,t){t(1),n.exports=t(3)},function(n,e,t){(function(){var e="undefined"!=typeof window?window.jQuery:t(2);n.exports.ThemeNav={navBar:null,win:null,winScroll:!1,winResize:!1,linkScroll:!1,winPosition:0,winHeight:null,docHeight:null,isRunning:!1,enable:function(n){var t=this;void 0===n&&(n=!0),t.isRunning||(t.isRunning=!0,e((function(e){t.init(e),t.reset(),t.win.on("hashchange",t.reset),n&&t.win.on("scroll",(function(){t.linkScroll||t.winScroll||(t.winScroll=!0,requestAnimationFrame((function(){t.onScroll()})))})),t.win.on("resize",(function(){t.winResize||(t.winResize=!0,requestAnimationFrame((function(){t.onResize()})))})),t.onResize()})))},enableSticky:function(){this.enable(!0)},init:function(n){n(document);var e=this;this.navBar=n("div.wy-side-scroll:first"),this.win=n(window),n(document).on("click","[data-toggle='wy-nav-top']",(function(){n("[data-toggle='wy-nav-shift']").toggleClass("shift"),n("[data-toggle='rst-versions']").toggleClass("shift")})).on("click",".wy-menu-vertical .current ul li a",(function(){var t=n(this);n("[data-toggle='wy-nav-shift']").removeClass("shift"),n("[data-toggle='rst-versions']").toggleClass("shift"),e.toggleCurrent(t),e.hashChange()})).on("click","[data-toggle='rst-current-version']",(function(){n("[data-toggle='rst-versions']").toggleClass("shift-up")})),n("table.docutils:not(.field-list,.footnote,.citation)").wrap("
"),n("table.docutils.footnote").wrap("
"),n("table.docutils.citation").wrap("
"),n(".wy-menu-vertical ul").not(".simple").siblings("a").each((function(){var t=n(this);expand=n(''),expand.on("click",(function(n){return e.toggleCurrent(t),n.stopPropagation(),!1})),t.prepend(expand)}))},reset:function(){var n=encodeURI(window.location.hash)||"#";try{var e=$(".wy-menu-vertical"),t=e.find('[href="'+n+'"]');if(0===t.length){var i=$('.document [id="'+n.substring(1)+'"]').closest("div.section");0===(t=e.find('[href="#'+i.attr("id")+'"]')).length&&(t=e.find('[href="#"]'))}t.length>0&&($(".wy-menu-vertical .current").removeClass("current"),t.addClass("current"),t.closest("li.toctree-l1").addClass("current"),t.closest("li.toctree-l1").parent().addClass("current"),t.closest("li.toctree-l1").addClass("current"),t.closest("li.toctree-l2").addClass("current"),t.closest("li.toctree-l3").addClass("current"),t.closest("li.toctree-l4").addClass("current"),t.closest("li.toctree-l5").addClass("current"),t[0].scrollIntoView())}catch(n){console.log("Error expanding nav for anchor",n)}},onScroll:function(){this.winScroll=!1;var n=this.win.scrollTop(),e=n+this.winHeight,t=this.navBar.scrollTop()+(n-this.winPosition);n<0||e>this.docHeight||(this.navBar.scrollTop(t),this.winPosition=n)},onResize:function(){this.winResize=!1,this.winHeight=this.win.height(),this.docHeight=$(document).height()},hashChange:function(){this.linkScroll=!0,this.win.one("hashchange",(function(){this.linkScroll=!1}))},toggleCurrent:function(n){var e=n.closest("li");e.siblings("li.current").removeClass("current"),e.siblings().find("li.current").removeClass("current"),e.find("> ul li.current").removeClass("current"),e.toggleClass("current")}},"undefined"!=typeof window&&(window.SphinxRtdTheme={Navigation:n.exports.ThemeNav,StickyNav:n.exports.ThemeNav}),function(){for(var n=0,e=["ms","moz","webkit","o"],t=0;t Union[dict, dict]: 19 | """ 20 | Import links and labels from csv files 21 | 22 | :param edge_csv: A CSV file containing edge data on each line: 23 | 0,4,2 that are u,v,w which stand for node 1, node 2, weight respectively 24 | :param label_id: A CSV file containing labels for nodes: 25 | 10,node_name which are ID,label for each node 26 | :param sep: A separator that is the boundary for distinct entities 27 | :return: links and label dataframes 28 | """ 29 | print("Importing files and making dataframes...") 30 | self._check_input_files(edge_csv, label_id) 31 | raw_adjacency_dictionary = pd.read_csv(edge_csv, sep=sep, *args, **kwargs) 32 | raw_label_dictionary = pd.read_csv(label_id, sep=sep, *args, **kwargs) 33 | # raw_adjacency_dictionary = raw_adjacency_dictionary.drop(['Weight'], axis=1) 34 | label_dictionary = {} 35 | for row in raw_label_dictionary.iterrows(): 36 | label_dictionary.update({row[1][0]: row[1][1]}) 37 | return raw_adjacency_dictionary, label_dictionary 38 | 39 | def _check_input_files(self, edge_csv: str, label_id: str) -> bool: 40 | """ 41 | Check if there is any input file. 42 | 43 | :param edge_csv: Path to the edge-list csv file 44 | :param label_id: Path to the label-id-list csv file 45 | :return: True on finishing successfully 46 | """ 47 | pathlib.Path("./inputs").mkdir(parents=True, exist_ok=True) 48 | right_nodes_count = random.randint(20, 30) 49 | left_nodes_count = random.randint(30, 40) 50 | if edge_csv == "./inputs/neighbour_matrix.csv": 51 | file_exists = os.path.isfile("./inputs/neighbour_matrix.csv") 52 | if not file_exists: 53 | self._generate_random_graph_edges(left_nodes_count, right_nodes_count) 54 | if label_id == "./inputs/id_labels.csv": 55 | file_exists = os.path.isfile("./inputs/id_labels.csv") 56 | if not file_exists: 57 | self._generate_random_graph_labels(left_nodes_count, right_nodes_count) 58 | return True 59 | 60 | def _generate_random_graph_labels( 61 | self, left_nodes_count: int, right_nodes_count: int 62 | ) -> bool: 63 | """ 64 | Generate Labels for randomly generated graph nodes by generate_random_graph_edges() function 65 | 66 | :param left_nodes_count: Number of the left-side nodes 67 | :param right_nodes_count: Number of the right-side nodes 68 | :return: True on success 69 | """ 70 | with open("./inputs/id_labels.csv", "w") as csvfile: 71 | file_writer = csv.writer( 72 | csvfile, delimiter=",", quotechar='"', quoting=csv.QUOTE_MINIMAL 73 | ) 74 | file_writer.writerow(["ID", "Label"]) 75 | for i in range(left_nodes_count): 76 | file_writer.writerow([i, f"left_node_{i}"]) 77 | for i in range(right_nodes_count): 78 | file_writer.writerow([i + 100, f"right_node_{i}"]) 79 | return True 80 | 81 | def _generate_random_graph_edges( 82 | self, left_nodes_count: int, right_nodes_count: int 83 | ) -> bool: 84 | """ 85 | Generate a random graph and write it to a CSV file 86 | 87 | :param left_nodes_count: Number of the left-side nodes 88 | :param right_nodes_count: Number of the right-side nodes 89 | :return: True on success 90 | """ 91 | with open("./inputs/neighbour_matrix.csv", "w") as csvfile: 92 | file_writer = csv.writer( 93 | csvfile, delimiter=",", quotechar='"', quoting=csv.QUOTE_MINIMAL 94 | ) 95 | rand_seed = right_nodes_count * left_nodes_count - ( 96 | (right_nodes_count * left_nodes_count) / 3 97 | ) 98 | rand_seed2 = right_nodes_count * left_nodes_count 99 | links_count = random.randint(int(rand_seed), int(rand_seed2)) 100 | file_writer.writerow(["left_side", "right_side", "Weight"]) 101 | for i in range(links_count): 102 | file_writer.writerow( 103 | [ 104 | random.randint(0, left_nodes_count), 105 | random.randint(0, right_nodes_count) + 100, 106 | random.randint(1, 3), 107 | ] 108 | ) 109 | 110 | return True 111 | -------------------------------------------------------------------------------- /docs/build/html/_static/pygments.css: -------------------------------------------------------------------------------- 1 | pre { line-height: 125%; margin: 0; } 2 | td.linenos pre { color: #000000; background-color: #f0f0f0; padding-left: 5px; padding-right: 5px; } 3 | span.linenos { color: #000000; background-color: #f0f0f0; padding-left: 5px; padding-right: 5px; } 4 | td.linenos pre.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } 5 | span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } 6 | .highlight .hll { background-color: #ffffcc } 7 | .highlight { background: #f3f2f1; } 8 | .highlight .c { color: #60a0b0; font-style: italic } /* Comment */ 9 | .highlight .err { border: 1px solid #FF0000 } /* Error */ 10 | .highlight .k { color: #007020; font-weight: bold } /* Keyword */ 11 | .highlight .o { color: #666666 } /* Operator */ 12 | .highlight .ch { color: #60a0b0; font-style: italic } /* Comment.Hashbang */ 13 | .highlight .cm { color: #60a0b0; font-style: italic } /* Comment.Multiline */ 14 | .highlight .cp { color: #007020 } /* Comment.Preproc */ 15 | .highlight .cpf { color: #60a0b0; font-style: italic } /* Comment.PreprocFile */ 16 | .highlight .c1 { color: #60a0b0; font-style: italic } /* Comment.Single */ 17 | .highlight .cs { color: #60a0b0; background-color: #fff0f0 } /* Comment.Special */ 18 | .highlight .gd { color: #A00000 } /* Generic.Deleted */ 19 | .highlight .ge { font-style: italic } /* Generic.Emph */ 20 | .highlight .gr { color: #FF0000 } /* Generic.Error */ 21 | .highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */ 22 | .highlight .gi { color: #00A000 } /* Generic.Inserted */ 23 | .highlight .go { color: #888888 } /* Generic.Output */ 24 | .highlight .gp { color: #c65d09; font-weight: bold } /* Generic.Prompt */ 25 | .highlight .gs { font-weight: bold } /* Generic.Strong */ 26 | .highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */ 27 | .highlight .gt { color: #0044DD } /* Generic.Traceback */ 28 | .highlight .kc { color: #007020; font-weight: bold } /* Keyword.Constant */ 29 | .highlight .kd { color: #007020; font-weight: bold } /* Keyword.Declaration */ 30 | .highlight .kn { color: #007020; font-weight: bold } /* Keyword.Namespace */ 31 | .highlight .kp { color: #007020 } /* Keyword.Pseudo */ 32 | .highlight .kr { color: #007020; font-weight: bold } /* Keyword.Reserved */ 33 | .highlight .kt { color: #902000 } /* Keyword.Type */ 34 | .highlight .m { color: #40a070 } /* Literal.Number */ 35 | .highlight .s { color: #4070a0 } /* Literal.String */ 36 | .highlight .na { color: #4070a0 } /* Name.Attribute */ 37 | .highlight .nb { color: #007020 } /* Name.Builtin */ 38 | .highlight .nc { color: #0e84b5; font-weight: bold } /* Name.Class */ 39 | .highlight .no { color: #60add5 } /* Name.Constant */ 40 | .highlight .nd { color: #555555; font-weight: bold } /* Name.Decorator */ 41 | .highlight .ni { color: #d55537; font-weight: bold } /* Name.Entity */ 42 | .highlight .ne { color: #007020 } /* Name.Exception */ 43 | .highlight .nf { color: #06287e } /* Name.Function */ 44 | .highlight .nl { color: #002070; font-weight: bold } /* Name.Label */ 45 | .highlight .nn { color: #0e84b5; font-weight: bold } /* Name.Namespace */ 46 | .highlight .nt { color: #062873; font-weight: bold } /* Name.Tag */ 47 | .highlight .nv { color: #bb60d5 } /* Name.Variable */ 48 | .highlight .ow { color: #007020; font-weight: bold } /* Operator.Word */ 49 | .highlight .w { color: #bbbbbb } /* Text.Whitespace */ 50 | .highlight .mb { color: #40a070 } /* Literal.Number.Bin */ 51 | .highlight .mf { color: #40a070 } /* Literal.Number.Float */ 52 | .highlight .mh { color: #40a070 } /* Literal.Number.Hex */ 53 | .highlight .mi { color: #40a070 } /* Literal.Number.Integer */ 54 | .highlight .mo { color: #40a070 } /* Literal.Number.Oct */ 55 | .highlight .sa { color: #4070a0 } /* Literal.String.Affix */ 56 | .highlight .sb { color: #4070a0 } /* Literal.String.Backtick */ 57 | .highlight .sc { color: #4070a0 } /* Literal.String.Char */ 58 | .highlight .dl { color: #4070a0 } /* Literal.String.Delimiter */ 59 | .highlight .sd { color: #4070a0; font-style: italic } /* Literal.String.Doc */ 60 | .highlight .s2 { color: #4070a0 } /* Literal.String.Double */ 61 | .highlight .se { color: #4070a0; font-weight: bold } /* Literal.String.Escape */ 62 | .highlight .sh { color: #4070a0 } /* Literal.String.Heredoc */ 63 | .highlight .si { color: #70a0d0; font-style: italic } /* Literal.String.Interpol */ 64 | .highlight .sx { color: #c65d09 } /* Literal.String.Other */ 65 | .highlight .sr { color: #235388 } /* Literal.String.Regex */ 66 | .highlight .s1 { color: #4070a0 } /* Literal.String.Single */ 67 | .highlight .ss { color: #517918 } /* Literal.String.Symbol */ 68 | .highlight .bp { color: #007020 } /* Name.Builtin.Pseudo */ 69 | .highlight .fm { color: #06287e } /* Name.Function.Magic */ 70 | .highlight .vc { color: #bb60d5 } /* Name.Variable.Class */ 71 | .highlight .vg { color: #bb60d5 } /* Name.Variable.Global */ 72 | .highlight .vi { color: #bb60d5 } /* Name.Variable.Instance */ 73 | .highlight .vm { color: #bb60d5 } /* Name.Variable.Magic */ 74 | .highlight .il { color: #40a070 } /* Literal.Number.Integer.Long */ -------------------------------------------------------------------------------- /docs/build/html/search.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Search — Bigraph Documentation 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 |
52 | 53 | 102 | 103 |
104 | 105 | 106 | 112 | 113 | 114 |
115 | 116 | 194 |
195 | 196 |
197 | 198 |
199 | 200 | 201 | 206 | 207 | 208 | 209 | 210 | 211 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | -------------------------------------------------------------------------------- /docs/build/html/modules.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | bigraph — Bigraph Documentation 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 |
49 | 50 | 99 | 100 |
101 | 102 | 103 | 109 | 110 | 111 |
112 | 113 | 214 |
215 | 216 |
217 | 218 |
219 | 220 | 221 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | -------------------------------------------------------------------------------- /docs/build/html/py-modindex.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Python Module Index — Bigraph Documentation 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 |
52 | 53 | 102 | 103 |
104 | 105 | 106 | 112 | 113 | 114 |
115 | 116 | 246 |
247 | 248 |
249 | 250 |
251 | 252 | 253 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | -------------------------------------------------------------------------------- /docs/build/html/intro.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Introduction — Bigraph Documentation 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 |
51 | 52 | 101 | 102 |
103 | 104 | 105 | 111 | 112 | 113 |
114 | 115 | 216 |
217 | 218 |
219 | 220 |
221 | 222 | 223 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | -------------------------------------------------------------------------------- /docs/build/html/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Welcome to d's documentation! — Bigraph Documentation 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 |
50 | 51 | 100 | 101 |
102 | 103 | 104 | 110 | 111 | 112 |
113 | 114 | 239 |
240 | 241 |
242 | 243 |
244 | 245 | 246 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | -------------------------------------------------------------------------------- /tests/data/inputs/neighbour_matrix.csv: -------------------------------------------------------------------------------- 1 | left_side,right_side,Weight 2 | 36,112,1 3 | 10,103,1 4 | 8,100,1 5 | 21,107,1 6 | 1,122,3 7 | 29,103,1 8 | 28,123,1 9 | 23,100,3 10 | 11,110,1 11 | 1,120,1 12 | 29,124,2 13 | 32,121,1 14 | 1,115,3 15 | 10,127,2 16 | 25,103,1 17 | 22,103,2 18 | 31,118,1 19 | 33,108,2 20 | 31,123,2 21 | 18,124,3 22 | 10,104,3 23 | 17,106,3 24 | 5,106,1 25 | 16,101,3 26 | 17,120,2 27 | 31,119,2 28 | 24,118,1 29 | 13,100,2 30 | 13,122,1 31 | 12,127,1 32 | 30,124,3 33 | 39,106,2 34 | 12,113,1 35 | 36,114,1 36 | 5,103,1 37 | 18,100,1 38 | 28,102,1 39 | 21,126,3 40 | 39,115,3 41 | 8,124,2 42 | 23,123,3 43 | 5,122,1 44 | 11,113,3 45 | 7,122,1 46 | 34,108,2 47 | 19,116,2 48 | 29,100,3 49 | 18,111,1 50 | 27,126,3 51 | 1,120,3 52 | 14,127,1 53 | 17,126,2 54 | 30,108,2 55 | 21,126,3 56 | 14,100,1 57 | 13,118,3 58 | 27,126,2 59 | 13,102,2 60 | 4,117,1 61 | 26,112,2 62 | 37,120,2 63 | 39,126,1 64 | 24,102,2 65 | 11,117,1 66 | 25,107,2 67 | 11,121,1 68 | 27,108,2 69 | 5,110,3 70 | 32,118,3 71 | 4,102,3 72 | 11,109,2 73 | 30,127,2 74 | 31,126,2 75 | 14,120,2 76 | 22,124,3 77 | 9,104,1 78 | 7,107,3 79 | 37,105,1 80 | 33,107,1 81 | 16,113,2 82 | 25,102,3 83 | 33,113,2 84 | 32,119,3 85 | 1,104,2 86 | 4,103,2 87 | 4,100,1 88 | 29,106,3 89 | 36,101,1 90 | 4,100,1 91 | 12,102,1 92 | 0,113,3 93 | 24,102,1 94 | 13,123,2 95 | 25,116,3 96 | 26,100,2 97 | 12,117,1 98 | 19,103,2 99 | 15,110,1 100 | 11,125,1 101 | 32,114,2 102 | 30,105,2 103 | 10,106,2 104 | 28,125,3 105 | 7,100,1 106 | 15,123,3 107 | 33,113,2 108 | 16,124,1 109 | 26,111,1 110 | 36,100,3 111 | 23,104,3 112 | 29,108,3 113 | 11,101,1 114 | 7,110,1 115 | 11,101,2 116 | 0,101,3 117 | 9,119,3 118 | 39,113,2 119 | 22,119,1 120 | 3,113,3 121 | 2,115,1 122 | 16,109,1 123 | 25,109,2 124 | 20,104,1 125 | 15,103,3 126 | 25,113,2 127 | 29,126,1 128 | 11,111,1 129 | 24,125,3 130 | 14,125,2 131 | 0,102,1 132 | 10,109,2 133 | 15,116,2 134 | 39,122,2 135 | 35,124,2 136 | 0,122,2 137 | 30,114,2 138 | 7,110,3 139 | 11,114,1 140 | 16,123,3 141 | 39,109,2 142 | 36,110,3 143 | 33,115,2 144 | 1,113,3 145 | 12,111,1 146 | 35,117,1 147 | 8,109,2 148 | 22,110,2 149 | 18,104,2 150 | 34,125,3 151 | 19,121,1 152 | 39,106,3 153 | 31,119,1 154 | 11,120,3 155 | 7,102,2 156 | 17,116,3 157 | 11,110,1 158 | 16,126,1 159 | 18,100,3 160 | 25,115,2 161 | 38,101,2 162 | 34,111,1 163 | 39,123,3 164 | 16,106,2 165 | 38,122,1 166 | 26,120,1 167 | 27,106,1 168 | 22,101,3 169 | 32,112,1 170 | 8,105,1 171 | 25,127,2 172 | 27,108,2 173 | 37,108,2 174 | 16,108,1 175 | 31,104,3 176 | 38,105,1 177 | 36,111,3 178 | 9,116,3 179 | 33,124,3 180 | 22,119,2 181 | 20,114,1 182 | 36,101,1 183 | 4,120,2 184 | 3,100,2 185 | 11,105,3 186 | 10,105,2 187 | 27,102,3 188 | 27,105,1 189 | 34,113,1 190 | 27,125,1 191 | 38,102,1 192 | 37,102,2 193 | 25,101,2 194 | 13,100,1 195 | 0,108,3 196 | 34,125,1 197 | 37,112,1 198 | 36,106,3 199 | 32,113,2 200 | 8,106,1 201 | 33,116,1 202 | 18,113,3 203 | 39,104,3 204 | 29,108,2 205 | 2,104,1 206 | 19,116,1 207 | 33,108,3 208 | 27,115,2 209 | 6,110,3 210 | 30,125,1 211 | 36,107,2 212 | 35,104,2 213 | 1,124,3 214 | 9,122,2 215 | 26,107,3 216 | 23,106,2 217 | 28,125,2 218 | 16,117,1 219 | 7,110,3 220 | 34,118,2 221 | 28,118,3 222 | 24,109,1 223 | 39,119,1 224 | 32,123,1 225 | 20,102,1 226 | 29,101,2 227 | 28,115,3 228 | 32,111,1 229 | 12,107,1 230 | 38,125,3 231 | 31,121,3 232 | 33,117,3 233 | 13,124,3 234 | 14,117,2 235 | 22,111,2 236 | 30,106,1 237 | 38,114,2 238 | 34,114,3 239 | 13,116,2 240 | 37,123,1 241 | 14,109,3 242 | 19,120,2 243 | 18,102,1 244 | 7,110,2 245 | 25,111,2 246 | 32,103,3 247 | 32,124,2 248 | 2,110,1 249 | 33,127,1 250 | 12,105,2 251 | 6,103,1 252 | 33,108,1 253 | 30,117,1 254 | 38,121,1 255 | 20,116,3 256 | 29,103,1 257 | 29,122,3 258 | 24,113,3 259 | 5,121,2 260 | 11,104,2 261 | 10,112,2 262 | 17,108,1 263 | 4,116,1 264 | 29,103,1 265 | 35,114,3 266 | 24,123,3 267 | 2,126,3 268 | 2,120,2 269 | 13,111,2 270 | 8,117,2 271 | 11,108,1 272 | 2,121,1 273 | 38,110,3 274 | 31,122,2 275 | 11,119,1 276 | 17,103,2 277 | 19,115,1 278 | 6,126,1 279 | 6,104,3 280 | 8,125,1 281 | 25,124,1 282 | 19,124,2 283 | 0,100,3 284 | 15,126,3 285 | 18,121,2 286 | 24,125,2 287 | 10,116,3 288 | 24,122,2 289 | 31,103,2 290 | 32,115,2 291 | 35,115,3 292 | 31,104,2 293 | 25,103,2 294 | 38,127,3 295 | 23,100,3 296 | 26,123,2 297 | 37,121,1 298 | 22,109,1 299 | 11,118,1 300 | 3,114,3 301 | 0,111,1 302 | 8,122,2 303 | 3,110,1 304 | 21,106,2 305 | 8,112,1 306 | 37,102,3 307 | 14,116,1 308 | 22,125,3 309 | 23,114,1 310 | 22,120,3 311 | 29,111,2 312 | 24,126,1 313 | 10,120,1 314 | 10,120,2 315 | 9,115,3 316 | 17,118,3 317 | 14,120,1 318 | 36,106,2 319 | 19,120,3 320 | 36,127,1 321 | 6,111,3 322 | 5,108,3 323 | 7,119,2 324 | 7,116,1 325 | 26,126,3 326 | 36,124,2 327 | 33,101,3 328 | 30,108,2 329 | 19,117,2 330 | 9,127,3 331 | 2,108,1 332 | 10,113,2 333 | 4,107,1 334 | 35,115,2 335 | 3,110,2 336 | 23,115,3 337 | 13,122,1 338 | 3,102,1 339 | 1,102,3 340 | 35,111,2 341 | 35,111,1 342 | 8,122,3 343 | 4,123,2 344 | 9,126,3 345 | 5,109,2 346 | 37,124,1 347 | 36,119,3 348 | 37,102,3 349 | 1,119,1 350 | 12,109,1 351 | 11,111,1 352 | 37,117,1 353 | 15,101,3 354 | 0,113,2 355 | 4,102,1 356 | 14,110,2 357 | 39,107,3 358 | 3,116,1 359 | 15,113,3 360 | 16,120,2 361 | 39,104,2 362 | 7,115,2 363 | 36,102,3 364 | 39,110,3 365 | 13,113,1 366 | 15,101,1 367 | 33,123,2 368 | 15,118,2 369 | 20,112,2 370 | 14,118,1 371 | 28,118,3 372 | 33,103,3 373 | 2,125,3 374 | 9,107,2 375 | 4,106,1 376 | 18,117,3 377 | 15,126,1 378 | 4,106,2 379 | 36,118,1 380 | 18,123,2 381 | 32,101,2 382 | 22,102,1 383 | 16,115,2 384 | 11,127,2 385 | 10,114,2 386 | 37,120,3 387 | 29,112,1 388 | 30,106,1 389 | 31,121,3 390 | 26,122,2 391 | 35,122,3 392 | 19,113,1 393 | 26,114,2 394 | 30,112,3 395 | 12,115,3 396 | 20,122,3 397 | 5,119,1 398 | 14,106,1 399 | 15,101,1 400 | 10,102,1 401 | 2,124,2 402 | 11,126,2 403 | 34,101,2 404 | 19,124,3 405 | 24,113,3 406 | 13,121,1 407 | 5,100,3 408 | 4,121,3 409 | 1,122,3 410 | 32,127,2 411 | 18,116,1 412 | 11,125,2 413 | 28,111,3 414 | 10,125,1 415 | 37,102,1 416 | 39,115,3 417 | 13,113,2 418 | 36,106,3 419 | 5,120,3 420 | 5,112,2 421 | 26,103,2 422 | 39,104,3 423 | 12,126,3 424 | 11,108,2 425 | 8,127,1 426 | 26,116,2 427 | 36,102,2 428 | 1,105,3 429 | 24,125,2 430 | 20,123,2 431 | 19,116,2 432 | 12,115,3 433 | 2,123,3 434 | 32,110,1 435 | 10,106,2 436 | 17,102,3 437 | 16,121,2 438 | 2,112,1 439 | 2,116,1 440 | 29,115,2 441 | 28,123,1 442 | 15,117,2 443 | 24,123,1 444 | 14,120,1 445 | 8,120,1 446 | 21,101,1 447 | 8,126,2 448 | 0,111,3 449 | 10,119,1 450 | 28,106,3 451 | 14,119,2 452 | 33,105,2 453 | 0,106,2 454 | 13,116,2 455 | 36,100,1 456 | 35,116,1 457 | 28,116,1 458 | 25,121,3 459 | 6,114,2 460 | 6,104,1 461 | 15,121,3 462 | 10,107,3 463 | 0,116,2 464 | 38,115,1 465 | 35,100,3 466 | 36,123,2 467 | 11,112,2 468 | 31,119,2 469 | 0,127,3 470 | 17,124,2 471 | 11,106,2 472 | 4,116,2 473 | 26,101,3 474 | 22,117,2 475 | 16,117,2 476 | 5,117,2 477 | 8,111,3 478 | 27,120,1 479 | 13,105,2 480 | 19,119,3 481 | 30,112,2 482 | 39,122,1 483 | 15,113,2 484 | 33,125,3 485 | 9,103,1 486 | 36,117,1 487 | 37,118,2 488 | 0,103,3 489 | 26,119,3 490 | 28,108,1 491 | 0,122,3 492 | 20,113,3 493 | 6,116,2 494 | 39,125,3 495 | 32,126,3 496 | 37,107,1 497 | 17,115,1 498 | 10,106,3 499 | 29,104,1 500 | 8,110,2 501 | 37,112,1 502 | 3,105,2 503 | 27,100,2 504 | 4,104,1 505 | 3,127,1 506 | 25,116,2 507 | 28,116,1 508 | 20,120,1 509 | 0,111,3 510 | 17,108,1 511 | 29,122,3 512 | 38,113,1 513 | 15,108,3 514 | 6,117,2 515 | 7,126,1 516 | 3,122,1 517 | 2,127,2 518 | 38,119,1 519 | 34,109,2 520 | 20,111,2 521 | 28,114,2 522 | 3,108,1 523 | 6,124,1 524 | 16,105,1 525 | 32,116,1 526 | 28,105,2 527 | 1,127,2 528 | 39,101,1 529 | 13,106,2 530 | 19,100,2 531 | 26,101,1 532 | 8,112,3 533 | 9,108,3 534 | 24,121,1 535 | 37,110,2 536 | 38,116,1 537 | 26,121,2 538 | 6,117,1 539 | 30,120,2 540 | 36,125,1 541 | 8,104,2 542 | 31,104,3 543 | 26,104,2 544 | 1,113,2 545 | 0,120,1 546 | 37,125,3 547 | 34,116,1 548 | 14,103,3 549 | 39,106,1 550 | 10,117,2 551 | 9,115,2 552 | 32,102,1 553 | 5,117,2 554 | 27,106,2 555 | 2,114,3 556 | 5,112,2 557 | 20,105,3 558 | 14,114,3 559 | 36,119,3 560 | 37,123,1 561 | 29,105,3 562 | 18,115,3 563 | 10,108,2 564 | 28,108,1 565 | 35,114,3 566 | 19,108,3 567 | 32,119,2 568 | 7,118,1 569 | 29,110,1 570 | 24,105,2 571 | 13,126,1 572 | 7,110,3 573 | 6,110,2 574 | 14,105,3 575 | 23,125,2 576 | 26,103,3 577 | 13,121,1 578 | 12,106,2 579 | 19,113,3 580 | 36,100,3 581 | 0,103,2 582 | 4,122,3 583 | 6,109,3 584 | 39,120,2 585 | 21,123,1 586 | 27,117,2 587 | 39,123,2 588 | 23,109,2 589 | 27,121,1 590 | 0,119,2 591 | 0,116,2 592 | 26,122,2 593 | 28,100,1 594 | 13,106,1 595 | 10,120,2 596 | 15,115,2 597 | 12,126,1 598 | 17,104,3 599 | 21,101,3 600 | 24,111,3 601 | 24,115,3 602 | 4,117,2 603 | 26,110,3 604 | 0,117,1 605 | 6,105,2 606 | 36,123,3 607 | 1,107,3 608 | 14,101,1 609 | 7,107,2 610 | 8,100,1 611 | 27,120,2 612 | 0,122,1 613 | 30,117,3 614 | 17,110,3 615 | 33,120,1 616 | 3,116,3 617 | 6,125,2 618 | 11,107,2 619 | 26,119,3 620 | 19,107,2 621 | 33,127,2 622 | 7,100,3 623 | 25,116,1 624 | 20,125,2 625 | 30,103,2 626 | 11,119,2 627 | 27,100,1 628 | 15,110,1 629 | 24,111,2 630 | 31,108,2 631 | 4,110,3 632 | 2,107,2 633 | 4,112,1 634 | 3,107,2 635 | 11,113,2 636 | 26,110,2 637 | 14,116,3 638 | 1,111,2 639 | 31,126,1 640 | 15,111,1 641 | 26,108,1 642 | 30,109,2 643 | 25,101,1 644 | 26,110,3 645 | 17,109,2 646 | 39,107,2 647 | 16,112,3 648 | 23,126,2 649 | 9,106,2 650 | 12,112,1 651 | 4,123,1 652 | 16,123,3 653 | 30,114,2 654 | 28,105,1 655 | 37,113,1 656 | 15,110,3 657 | 29,112,2 658 | 28,109,3 659 | 6,109,2 660 | 28,113,3 661 | 28,105,3 662 | 35,117,2 663 | 17,119,1 664 | 22,102,2 665 | 22,119,2 666 | 15,100,3 667 | 5,109,1 668 | 5,110,2 669 | 31,112,2 670 | 4,120,3 671 | 4,103,3 672 | 15,100,2 673 | 32,102,1 674 | 36,118,3 675 | 2,120,2 676 | 28,107,1 677 | 6,114,3 678 | 6,109,3 679 | 2,124,2 680 | 27,115,3 681 | 15,104,3 682 | 29,104,2 683 | 37,114,1 684 | 28,112,1 685 | 33,109,3 686 | 31,111,2 687 | 14,105,1 688 | 19,125,2 689 | 39,127,2 690 | 31,107,3 691 | 4,109,2 692 | 25,109,2 693 | 11,109,1 694 | 37,122,1 695 | 3,110,1 696 | 25,112,2 697 | 34,109,1 698 | 23,102,3 699 | 11,118,3 700 | 20,124,2 701 | 26,118,3 702 | 37,106,3 703 | 2,117,2 704 | -------------------------------------------------------------------------------- /docs/build/html/bigraph.evaluation.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | bigraph.evaluation package — Bigraph Documentation 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 |
51 | 52 | 105 | 106 |
107 | 108 | 109 | 115 | 116 | 117 |
118 | 119 | 251 |
252 | 253 |
254 | 255 |
256 | 257 | 258 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | -------------------------------------------------------------------------------- /docs/build/html/_static/doctools.js: -------------------------------------------------------------------------------- 1 | /* 2 | * doctools.js 3 | * ~~~~~~~~~~~ 4 | * 5 | * Sphinx JavaScript utilities for all documentation. 6 | * 7 | * :copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS. 8 | * :license: BSD, see LICENSE for details. 9 | * 10 | */ 11 | 12 | /** 13 | * select a different prefix for underscore 14 | */ 15 | $u = _.noConflict(); 16 | 17 | /** 18 | * make the code below compatible with browsers without 19 | * an installed firebug like debugger 20 | if (!window.console || !console.firebug) { 21 | var names = ["log", "debug", "info", "warn", "error", "assert", "dir", 22 | "dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace", 23 | "profile", "profileEnd"]; 24 | window.console = {}; 25 | for (var i = 0; i < names.length; ++i) 26 | window.console[names[i]] = function() {}; 27 | } 28 | */ 29 | 30 | /** 31 | * small helper function to urldecode strings 32 | */ 33 | jQuery.urldecode = function(x) { 34 | return decodeURIComponent(x).replace(/\+/g, ' '); 35 | }; 36 | 37 | /** 38 | * small helper function to urlencode strings 39 | */ 40 | jQuery.urlencode = encodeURIComponent; 41 | 42 | /** 43 | * This function returns the parsed url parameters of the 44 | * current request. Multiple values per key are supported, 45 | * it will always return arrays of strings for the value parts. 46 | */ 47 | jQuery.getQueryParameters = function(s) { 48 | if (typeof s === 'undefined') 49 | s = document.location.search; 50 | var parts = s.substr(s.indexOf('?') + 1).split('&'); 51 | var result = {}; 52 | for (var i = 0; i < parts.length; i++) { 53 | var tmp = parts[i].split('=', 2); 54 | var key = jQuery.urldecode(tmp[0]); 55 | var value = jQuery.urldecode(tmp[1]); 56 | if (key in result) 57 | result[key].push(value); 58 | else 59 | result[key] = [value]; 60 | } 61 | return result; 62 | }; 63 | 64 | /** 65 | * highlight a given string on a jquery object by wrapping it in 66 | * span elements with the given class name. 67 | */ 68 | jQuery.fn.highlightText = function(text, className) { 69 | function highlight(node, addItems) { 70 | if (node.nodeType === 3) { 71 | var val = node.nodeValue; 72 | var pos = val.toLowerCase().indexOf(text); 73 | if (pos >= 0 && 74 | !jQuery(node.parentNode).hasClass(className) && 75 | !jQuery(node.parentNode).hasClass("nohighlight")) { 76 | var span; 77 | var isInSVG = jQuery(node).closest("body, svg, foreignObject").is("svg"); 78 | if (isInSVG) { 79 | span = document.createElementNS("http://www.w3.org/2000/svg", "tspan"); 80 | } else { 81 | span = document.createElement("span"); 82 | span.className = className; 83 | } 84 | span.appendChild(document.createTextNode(val.substr(pos, text.length))); 85 | node.parentNode.insertBefore(span, node.parentNode.insertBefore( 86 | document.createTextNode(val.substr(pos + text.length)), 87 | node.nextSibling)); 88 | node.nodeValue = val.substr(0, pos); 89 | if (isInSVG) { 90 | var rect = document.createElementNS("http://www.w3.org/2000/svg", "rect"); 91 | var bbox = node.parentElement.getBBox(); 92 | rect.x.baseVal.value = bbox.x; 93 | rect.y.baseVal.value = bbox.y; 94 | rect.width.baseVal.value = bbox.width; 95 | rect.height.baseVal.value = bbox.height; 96 | rect.setAttribute('class', className); 97 | addItems.push({ 98 | "parent": node.parentNode, 99 | "target": rect}); 100 | } 101 | } 102 | } 103 | else if (!jQuery(node).is("button, select, textarea")) { 104 | jQuery.each(node.childNodes, function() { 105 | highlight(this, addItems); 106 | }); 107 | } 108 | } 109 | var addItems = []; 110 | var result = this.each(function() { 111 | highlight(this, addItems); 112 | }); 113 | for (var i = 0; i < addItems.length; ++i) { 114 | jQuery(addItems[i].parent).before(addItems[i].target); 115 | } 116 | return result; 117 | }; 118 | 119 | /* 120 | * backward compatibility for jQuery.browser 121 | * This will be supported until firefox bug is fixed. 122 | */ 123 | if (!jQuery.browser) { 124 | jQuery.uaMatch = function(ua) { 125 | ua = ua.toLowerCase(); 126 | 127 | var match = /(chrome)[ \/]([\w.]+)/.exec(ua) || 128 | /(webkit)[ \/]([\w.]+)/.exec(ua) || 129 | /(opera)(?:.*version|)[ \/]([\w.]+)/.exec(ua) || 130 | /(msie) ([\w.]+)/.exec(ua) || 131 | ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(ua) || 132 | []; 133 | 134 | return { 135 | browser: match[ 1 ] || "", 136 | version: match[ 2 ] || "0" 137 | }; 138 | }; 139 | jQuery.browser = {}; 140 | jQuery.browser[jQuery.uaMatch(navigator.userAgent).browser] = true; 141 | } 142 | 143 | /** 144 | * Small JavaScript module for the documentation. 145 | */ 146 | var Documentation = { 147 | 148 | init : function() { 149 | this.fixFirefoxAnchorBug(); 150 | this.highlightSearchWords(); 151 | this.initIndexTable(); 152 | if (DOCUMENTATION_OPTIONS.NAVIGATION_WITH_KEYS) { 153 | this.initOnKeyListeners(); 154 | } 155 | }, 156 | 157 | /** 158 | * i18n support 159 | */ 160 | TRANSLATIONS : {}, 161 | PLURAL_EXPR : function(n) { return n === 1 ? 0 : 1; }, 162 | LOCALE : 'unknown', 163 | 164 | // gettext and ngettext don't access this so that the functions 165 | // can safely bound to a different name (_ = Documentation.gettext) 166 | gettext : function(string) { 167 | var translated = Documentation.TRANSLATIONS[string]; 168 | if (typeof translated === 'undefined') 169 | return string; 170 | return (typeof translated === 'string') ? translated : translated[0]; 171 | }, 172 | 173 | ngettext : function(singular, plural, n) { 174 | var translated = Documentation.TRANSLATIONS[singular]; 175 | if (typeof translated === 'undefined') 176 | return (n == 1) ? singular : plural; 177 | return translated[Documentation.PLURALEXPR(n)]; 178 | }, 179 | 180 | addTranslations : function(catalog) { 181 | for (var key in catalog.messages) 182 | this.TRANSLATIONS[key] = catalog.messages[key]; 183 | this.PLURAL_EXPR = new Function('n', 'return +(' + catalog.plural_expr + ')'); 184 | this.LOCALE = catalog.locale; 185 | }, 186 | 187 | /** 188 | * add context elements like header anchor links 189 | */ 190 | addContextElements : function() { 191 | $('div[id] > :header:first').each(function() { 192 | $('\u00B6'). 193 | attr('href', '#' + this.id). 194 | attr('title', _('Permalink to this headline')). 195 | appendTo(this); 196 | }); 197 | $('dt[id]').each(function() { 198 | $('\u00B6'). 199 | attr('href', '#' + this.id). 200 | attr('title', _('Permalink to this definition')). 201 | appendTo(this); 202 | }); 203 | }, 204 | 205 | /** 206 | * workaround a firefox stupidity 207 | * see: https://bugzilla.mozilla.org/show_bug.cgi?id=645075 208 | */ 209 | fixFirefoxAnchorBug : function() { 210 | if (document.location.hash && $.browser.mozilla) 211 | window.setTimeout(function() { 212 | document.location.href += ''; 213 | }, 10); 214 | }, 215 | 216 | /** 217 | * highlight the search words provided in the url in the text 218 | */ 219 | highlightSearchWords : function() { 220 | var params = $.getQueryParameters(); 221 | var terms = (params.highlight) ? params.highlight[0].split(/\s+/) : []; 222 | if (terms.length) { 223 | var body = $('div.body'); 224 | if (!body.length) { 225 | body = $('body'); 226 | } 227 | window.setTimeout(function() { 228 | $.each(terms, function() { 229 | body.highlightText(this.toLowerCase(), 'highlighted'); 230 | }); 231 | }, 10); 232 | $('') 234 | .appendTo($('#searchbox')); 235 | } 236 | }, 237 | 238 | /** 239 | * init the domain index toggle buttons 240 | */ 241 | initIndexTable : function() { 242 | var togglers = $('img.toggler').click(function() { 243 | var src = $(this).attr('src'); 244 | var idnum = $(this).attr('id').substr(7); 245 | $('tr.cg-' + idnum).toggle(); 246 | if (src.substr(-9) === 'minus.png') 247 | $(this).attr('src', src.substr(0, src.length-9) + 'plus.png'); 248 | else 249 | $(this).attr('src', src.substr(0, src.length-8) + 'minus.png'); 250 | }).css('display', ''); 251 | if (DOCUMENTATION_OPTIONS.COLLAPSE_INDEX) { 252 | togglers.click(); 253 | } 254 | }, 255 | 256 | /** 257 | * helper function to hide the search marks again 258 | */ 259 | hideSearchWords : function() { 260 | $('#searchbox .highlight-link').fadeOut(300); 261 | $('span.highlighted').removeClass('highlighted'); 262 | }, 263 | 264 | /** 265 | * make the url absolute 266 | */ 267 | makeURL : function(relativeURL) { 268 | return DOCUMENTATION_OPTIONS.URL_ROOT + '/' + relativeURL; 269 | }, 270 | 271 | /** 272 | * get the current relative url 273 | */ 274 | getCurrentURL : function() { 275 | var path = document.location.pathname; 276 | var parts = path.split(/\//); 277 | $.each(DOCUMENTATION_OPTIONS.URL_ROOT.split(/\//), function() { 278 | if (this === '..') 279 | parts.pop(); 280 | }); 281 | var url = parts.join('/'); 282 | return path.substring(url.lastIndexOf('/') + 1, path.length - 1); 283 | }, 284 | 285 | initOnKeyListeners: function() { 286 | $(document).keydown(function(event) { 287 | var activeElementType = document.activeElement.tagName; 288 | // don't navigate when in search box or textarea 289 | if (activeElementType !== 'TEXTAREA' && activeElementType !== 'INPUT' && activeElementType !== 'SELECT' 290 | && !event.altKey && !event.ctrlKey && !event.metaKey && !event.shiftKey) { 291 | switch (event.keyCode) { 292 | case 37: // left 293 | var prevHref = $('link[rel="prev"]').prop('href'); 294 | if (prevHref) { 295 | window.location.href = prevHref; 296 | return false; 297 | } 298 | case 39: // right 299 | var nextHref = $('link[rel="next"]').prop('href'); 300 | if (nextHref) { 301 | window.location.href = nextHref; 302 | return false; 303 | } 304 | } 305 | } 306 | }); 307 | } 308 | }; 309 | 310 | // quick alias for translations 311 | _ = Documentation.gettext; 312 | 313 | $(document).ready(function() { 314 | Documentation.init(); 315 | }); 316 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

BiGraph

2 |
3 | PyPI version 4 | PyPI version 5 | PyPI - Python Version 6 | 7 | [comment]: <> (PyPI - Downloads) 8 | 9 | [comment]: <> (PyPI - Downloads) 10 | 11 | [comment]: <> (GitHub search hit counter) 12 | 13 | [comment]: <> (GitHub search hit counter) 14 | 15 | [comment]: <> (PyPI - Implementation) 16 | 17 | [comment]: <> (GitHub commit activity) 18 | 19 | [comment]: <> (GitHub last commit) 20 | GitHub Repo stars 21 |
22 |

BiGraph is a Python package for Link prediction in bipartite networks.

23 | 24 |
    25 |
  • Bug reports: https://github.com/bi-graph/bigraph/issues
  • 26 |
27 | 28 | > Node based similarities and Katz has been implemented. you can find algorithms in bigraph module. Algorithms implemented so far: 29 | 30 |
31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 |
Algorithms table
NumberAlgorithm
1jaccard
2adamic adar
3common neighbors
4 preferential attachment
5katz similarity
58 |
59 | 60 |
61 |

Installation

62 |

Install the latest version of BiGraph:

63 |
$ pip install bigraph
64 |
65 | 66 |
67 |

Documentation

68 |

https://bigraph.readthedocs.io/en/latest/

69 | 70 |
71 | 72 |

Simple example

73 |

Predicting new links in a randomly generated graph using 74 | Adamic-Adar algorithm:

75 | 76 | ```python 77 | from bigraph.predict import aa_predict 78 | from bigraph.preprocessing import import_files, make_graph 79 | 80 | 81 | def adamic_adar_prediction(): 82 | """ 83 | Link prediction on bipartite networks 84 | :return: A dictionary containing predicted links 85 | """ 86 | 87 | df, df_nodes = import_files() 88 | print(df) 89 | print(f"Graph Nodes: ", df_nodes) 90 | G = make_graph(df) 91 | print(G) 92 | predicted = aa_predict(G) # Here we have called Adamic Adar method from bigraph module 93 | return predicted 94 | 95 | 96 | # Executing the function 97 | 98 | if __name__ == '__main__': 99 | adamic_adar_prediction() 100 | ``` 101 | 102 |

Evaluating Adamic-Adar algorithm.
103 | You can try other provided prediction algorithms by replacing the "aa" argument.

104 | 105 | ```python 106 | from bigraph.evaluation.evaluation import evaluate 107 | from bigraph.preprocessing import import_files, make_graph 108 | 109 | 110 | def adamic_adar_evaluation(): 111 | """ 112 | Evaluate Adamic-Adar algorithm using 10-Fold cross-validation 113 | :return: A dictionary containing the evaluation results 114 | """ 115 | df, df_nodes = import_files() 116 | G = make_graph(df) 117 | results = evaluate(G, k=10, 118 | method='aa') # Here we have evaluated adamic-adar 119 | # methods using evaluation module. Methods are 'jc', 'aa', 'pa', 'cn' 120 | return results 121 | 122 | 123 | # Executing the function 124 | if __name__ == '__main__': 125 | adamic_adar_evaluation() 126 | ``` 127 |
128 |

Call for Contributions

129 |

The Bigraph project welcomes your expertise and enthusiasm!

130 | 131 |

Ways to contribute to Bigraph:

132 |
    133 |
  • Writing code
  • 134 |
  • Review pull requests
  • 135 |
  • Develop tutorials, presentations, and other educational materials
  • 136 |
  • Translate documentation and readme contents
  • 137 |
138 |
139 | 140 |
141 |

Issues

142 |

If you happened to encounter any issue in the codes, please report it 143 | here. 144 | A better way is to fork the repository on Github and/or create a pull request.

145 | 146 |
147 | 148 | 149 |

Metrics

150 |

Metrics that are calculated during evaluation:

151 | 152 |
153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 |
Metrics table
NumberEvaluattion metrics
1Precision
2AUC
3ROC
4returns fpr*
5returns tpr*
180 |
181 | 182 | > * For further usages and calculating different metrics 183 | 184 |

Dataset format

185 |

Your dataset should be in the following format (Exclude the 'Row' column):

186 | 187 |
188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 |
Sample edges (links) dataset
Rowleft_sideright_sideWeight*
1u0v11
2u2v11
3u1v21
4u3v31
5u4v32
227 |
228 | 229 | > * Note that running
230 | from bigraph.preprocessing import import_files
231 | df, df_nodes = import_files()
will create a sample graph for you and will place it in the 232 | inputs directory. 233 | > * Although the weight has not been involved in current version, but, the format will be the same. 234 | 235 |

More examples

236 |

Predicting new links in a randomly generated graph using following algorithms:

237 |
    238 |
  • Preferential attachment
  • 239 |
  • Jaccard similarity
  • 240 |
  • Common neighbours
  • 241 |
242 | 243 | ```python 244 | from bigraph.predict import pa_predict, jc_predict, cn_predict 245 | from bigraph.preprocessing import import_files, make_graph 246 | 247 | 248 | def main(): 249 | """ 250 | Link prediction on bipartite networks 251 | :return: 252 | """ 253 | df, df_nodes = import_files() 254 | G = make_graph(df) 255 | pa_predict(G) # Preferential attachment 256 | jc_predict(G) # Jaccard coefficient 257 | cn_predict(G) # Common neighbors 258 | 259 | 260 | # Executing the function 261 | if __name__ == '__main__': 262 | main() 263 | ``` 264 | 265 |

References

266 | 267 |
268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 279 | 280 | 281 | 282 | 283 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 |
References table
NumberReferenceYear
1Yang, Y., Lichtenwalter, R.N. & Chawla, N.V. Evaluating link prediction methods. Knowl Inf Syst 45, 751–782 (2015). https://doi.org/10.1007/s10115-014-0789-02015
2Liben-nowell, David & Kleinberg, Jon. (2003). The Link Prediction Problem for Social Networks. Journal of the American Society for Information Science and Technology.https://doi.org/58.10.1002/asi.205912003
2......
293 |
294 | 295 |

Future work

296 | 297 | - [x] Modulate the functions 298 | - [ ] Add more algorithms 299 | - [ ] Run on CUDA cores 300 | - [ ] Make it faster using vectorization etc. 301 | - [ ] Add more preprocessors 302 | - [ ] Add dataset, graph, and dataframe manipulations 303 | - [ ] Unify and reconstruct the architecture and eliminate redundancy 304 | 305 | 306 |

Notes

307 |
    308 |
  • 309 | It can export the graph in .json and .gexf format 310 | for further usages. For instance: Gephi etc. 311 |
  • 312 |
313 | 314 | 315 |

If you found it helpful, please give us a :star:

316 | 317 |

License

318 |

Released under the BSD license

319 | 323 | -------------------------------------------------------------------------------- /docs/build/html/_static/underscore.js: -------------------------------------------------------------------------------- 1 | // Underscore.js 1.3.1 2 | // (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc. 3 | // Underscore is freely distributable under the MIT license. 4 | // Portions of Underscore are inspired or borrowed from Prototype, 5 | // Oliver Steele's Functional, and John Resig's Micro-Templating. 6 | // For all details and documentation: 7 | // http://documentcloud.github.com/underscore 8 | (function(){function q(a,c,d){if(a===c)return a!==0||1/a==1/c;if(a==null||c==null)return a===c;if(a._chain)a=a._wrapped;if(c._chain)c=c._wrapped;if(a.isEqual&&b.isFunction(a.isEqual))return a.isEqual(c);if(c.isEqual&&b.isFunction(c.isEqual))return c.isEqual(a);var e=l.call(a);if(e!=l.call(c))return false;switch(e){case "[object String]":return a==String(c);case "[object Number]":return a!=+a?c!=+c:a==0?1/a==1/c:a==+c;case "[object Date]":case "[object Boolean]":return+a==+c;case "[object RegExp]":return a.source== 9 | c.source&&a.global==c.global&&a.multiline==c.multiline&&a.ignoreCase==c.ignoreCase}if(typeof a!="object"||typeof c!="object")return false;for(var f=d.length;f--;)if(d[f]==a)return true;d.push(a);var f=0,g=true;if(e=="[object Array]"){if(f=a.length,g=f==c.length)for(;f--;)if(!(g=f in a==f in c&&q(a[f],c[f],d)))break}else{if("constructor"in a!="constructor"in c||a.constructor!=c.constructor)return false;for(var h in a)if(b.has(a,h)&&(f++,!(g=b.has(c,h)&&q(a[h],c[h],d))))break;if(g){for(h in c)if(b.has(c, 10 | h)&&!f--)break;g=!f}}d.pop();return g}var r=this,G=r._,n={},k=Array.prototype,o=Object.prototype,i=k.slice,H=k.unshift,l=o.toString,I=o.hasOwnProperty,w=k.forEach,x=k.map,y=k.reduce,z=k.reduceRight,A=k.filter,B=k.every,C=k.some,p=k.indexOf,D=k.lastIndexOf,o=Array.isArray,J=Object.keys,s=Function.prototype.bind,b=function(a){return new m(a)};if(typeof exports!=="undefined"){if(typeof module!=="undefined"&&module.exports)exports=module.exports=b;exports._=b}else r._=b;b.VERSION="1.3.1";var j=b.each= 11 | b.forEach=function(a,c,d){if(a!=null)if(w&&a.forEach===w)a.forEach(c,d);else if(a.length===+a.length)for(var e=0,f=a.length;e2;a== 12 | null&&(a=[]);if(y&&a.reduce===y)return e&&(c=b.bind(c,e)),f?a.reduce(c,d):a.reduce(c);j(a,function(a,b,i){f?d=c.call(e,d,a,b,i):(d=a,f=true)});if(!f)throw new TypeError("Reduce of empty array with no initial value");return d};b.reduceRight=b.foldr=function(a,c,d,e){var f=arguments.length>2;a==null&&(a=[]);if(z&&a.reduceRight===z)return e&&(c=b.bind(c,e)),f?a.reduceRight(c,d):a.reduceRight(c);var g=b.toArray(a).reverse();e&&!f&&(c=b.bind(c,e));return f?b.reduce(g,c,d,e):b.reduce(g,c)};b.find=b.detect= 13 | function(a,c,b){var e;E(a,function(a,g,h){if(c.call(b,a,g,h))return e=a,true});return e};b.filter=b.select=function(a,c,b){var e=[];if(a==null)return e;if(A&&a.filter===A)return a.filter(c,b);j(a,function(a,g,h){c.call(b,a,g,h)&&(e[e.length]=a)});return e};b.reject=function(a,c,b){var e=[];if(a==null)return e;j(a,function(a,g,h){c.call(b,a,g,h)||(e[e.length]=a)});return e};b.every=b.all=function(a,c,b){var e=true;if(a==null)return e;if(B&&a.every===B)return a.every(c,b);j(a,function(a,g,h){if(!(e= 14 | e&&c.call(b,a,g,h)))return n});return e};var E=b.some=b.any=function(a,c,d){c||(c=b.identity);var e=false;if(a==null)return e;if(C&&a.some===C)return a.some(c,d);j(a,function(a,b,h){if(e||(e=c.call(d,a,b,h)))return n});return!!e};b.include=b.contains=function(a,c){var b=false;if(a==null)return b;return p&&a.indexOf===p?a.indexOf(c)!=-1:b=E(a,function(a){return a===c})};b.invoke=function(a,c){var d=i.call(arguments,2);return b.map(a,function(a){return(b.isFunction(c)?c||a:a[c]).apply(a,d)})};b.pluck= 15 | function(a,c){return b.map(a,function(a){return a[c]})};b.max=function(a,c,d){if(!c&&b.isArray(a))return Math.max.apply(Math,a);if(!c&&b.isEmpty(a))return-Infinity;var e={computed:-Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;b>=e.computed&&(e={value:a,computed:b})});return e.value};b.min=function(a,c,d){if(!c&&b.isArray(a))return Math.min.apply(Math,a);if(!c&&b.isEmpty(a))return Infinity;var e={computed:Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;bd?1:0}),"value")};b.groupBy=function(a,c){var d={},e=b.isFunction(c)?c:function(a){return a[c]};j(a,function(a,b){var c=e(a,b);(d[c]||(d[c]=[])).push(a)});return d};b.sortedIndex=function(a, 17 | c,d){d||(d=b.identity);for(var e=0,f=a.length;e>1;d(a[g])=0})})};b.difference=function(a){var c=b.flatten(i.call(arguments,1));return b.filter(a,function(a){return!b.include(c,a)})};b.zip=function(){for(var a=i.call(arguments),c=b.max(b.pluck(a,"length")),d=Array(c),e=0;e=0;d--)b=[a[d].apply(this,b)];return b[0]}}; 24 | b.after=function(a,b){return a<=0?b():function(){if(--a<1)return b.apply(this,arguments)}};b.keys=J||function(a){if(a!==Object(a))throw new TypeError("Invalid object");var c=[],d;for(d in a)b.has(a,d)&&(c[c.length]=d);return c};b.values=function(a){return b.map(a,b.identity)};b.functions=b.methods=function(a){var c=[],d;for(d in a)b.isFunction(a[d])&&c.push(d);return c.sort()};b.extend=function(a){j(i.call(arguments,1),function(b){for(var d in b)a[d]=b[d]});return a};b.defaults=function(a){j(i.call(arguments, 25 | 1),function(b){for(var d in b)a[d]==null&&(a[d]=b[d])});return a};b.clone=function(a){return!b.isObject(a)?a:b.isArray(a)?a.slice():b.extend({},a)};b.tap=function(a,b){b(a);return a};b.isEqual=function(a,b){return q(a,b,[])};b.isEmpty=function(a){if(b.isArray(a)||b.isString(a))return a.length===0;for(var c in a)if(b.has(a,c))return false;return true};b.isElement=function(a){return!!(a&&a.nodeType==1)};b.isArray=o||function(a){return l.call(a)=="[object Array]"};b.isObject=function(a){return a===Object(a)}; 26 | b.isArguments=function(a){return l.call(a)=="[object Arguments]"};if(!b.isArguments(arguments))b.isArguments=function(a){return!(!a||!b.has(a,"callee"))};b.isFunction=function(a){return l.call(a)=="[object Function]"};b.isString=function(a){return l.call(a)=="[object String]"};b.isNumber=function(a){return l.call(a)=="[object Number]"};b.isNaN=function(a){return a!==a};b.isBoolean=function(a){return a===true||a===false||l.call(a)=="[object Boolean]"};b.isDate=function(a){return l.call(a)=="[object Date]"}; 27 | b.isRegExp=function(a){return l.call(a)=="[object RegExp]"};b.isNull=function(a){return a===null};b.isUndefined=function(a){return a===void 0};b.has=function(a,b){return I.call(a,b)};b.noConflict=function(){r._=G;return this};b.identity=function(a){return a};b.times=function(a,b,d){for(var e=0;e/g,">").replace(/"/g,""").replace(/'/g,"'").replace(/\//g,"/")};b.mixin=function(a){j(b.functions(a), 28 | function(c){K(c,b[c]=a[c])})};var L=0;b.uniqueId=function(a){var b=L++;return a?a+b:b};b.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var t=/.^/,u=function(a){return a.replace(/\\\\/g,"\\").replace(/\\'/g,"'")};b.template=function(a,c){var d=b.templateSettings,d="var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('"+a.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(d.escape||t,function(a,b){return"',_.escape("+ 29 | u(b)+"),'"}).replace(d.interpolate||t,function(a,b){return"',"+u(b)+",'"}).replace(d.evaluate||t,function(a,b){return"');"+u(b).replace(/[\r\n\t]/g," ")+";__p.push('"}).replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace(/\t/g,"\\t")+"');}return __p.join('');",e=new Function("obj","_",d);return c?e(c,b):function(a){return e.call(this,a,b)}};b.chain=function(a){return b(a).chain()};var m=function(a){this._wrapped=a};b.prototype=m.prototype;var v=function(a,c){return c?b(a).chain():a},K=function(a,c){m.prototype[a]= 30 | function(){var a=i.call(arguments);H.call(a,this._wrapped);return v(c.apply(b,a),this._chain)}};b.mixin(b);j("pop,push,reverse,shift,sort,splice,unshift".split(","),function(a){var b=k[a];m.prototype[a]=function(){var d=this._wrapped;b.apply(d,arguments);var e=d.length;(a=="shift"||a=="splice")&&e===0&&delete d[0];return v(d,this._chain)}});j(["concat","join","slice"],function(a){var b=k[a];m.prototype[a]=function(){return v(b.apply(this._wrapped,arguments),this._chain)}});m.prototype.chain=function(){this._chain= 31 | true;return this};m.prototype.value=function(){return this._wrapped}}).call(this); 32 | -------------------------------------------------------------------------------- /docs/build/html/_static/language_data.js: -------------------------------------------------------------------------------- 1 | /* 2 | * language_data.js 3 | * ~~~~~~~~~~~~~~~~ 4 | * 5 | * This script contains the language-specific data used by searchtools.js, 6 | * namely the list of stopwords, stemmer, scorer and splitter. 7 | * 8 | * :copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS. 9 | * :license: BSD, see LICENSE for details. 10 | * 11 | */ 12 | 13 | var stopwords = ["a","and","are","as","at","be","but","by","for","if","in","into","is","it","near","no","not","of","on","or","such","that","the","their","then","there","these","they","this","to","was","will","with"]; 14 | 15 | 16 | /* Non-minified version JS is _stemmer.js if file is provided */ 17 | /** 18 | * Porter Stemmer 19 | */ 20 | var Stemmer = function() { 21 | 22 | var step2list = { 23 | ational: 'ate', 24 | tional: 'tion', 25 | enci: 'ence', 26 | anci: 'ance', 27 | izer: 'ize', 28 | bli: 'ble', 29 | alli: 'al', 30 | entli: 'ent', 31 | eli: 'e', 32 | ousli: 'ous', 33 | ization: 'ize', 34 | ation: 'ate', 35 | ator: 'ate', 36 | alism: 'al', 37 | iveness: 'ive', 38 | fulness: 'ful', 39 | ousness: 'ous', 40 | aliti: 'al', 41 | iviti: 'ive', 42 | biliti: 'ble', 43 | logi: 'log' 44 | }; 45 | 46 | var step3list = { 47 | icate: 'ic', 48 | ative: '', 49 | alize: 'al', 50 | iciti: 'ic', 51 | ical: 'ic', 52 | ful: '', 53 | ness: '' 54 | }; 55 | 56 | var c = "[^aeiou]"; // consonant 57 | var v = "[aeiouy]"; // vowel 58 | var C = c + "[^aeiouy]*"; // consonant sequence 59 | var V = v + "[aeiou]*"; // vowel sequence 60 | 61 | var mgr0 = "^(" + C + ")?" + V + C; // [C]VC... is m>0 62 | var meq1 = "^(" + C + ")?" + V + C + "(" + V + ")?$"; // [C]VC[V] is m=1 63 | var mgr1 = "^(" + C + ")?" + V + C + V + C; // [C]VCVC... is m>1 64 | var s_v = "^(" + C + ")?" + v; // vowel in stem 65 | 66 | this.stemWord = function (w) { 67 | var stem; 68 | var suffix; 69 | var firstch; 70 | var origword = w; 71 | 72 | if (w.length < 3) 73 | return w; 74 | 75 | var re; 76 | var re2; 77 | var re3; 78 | var re4; 79 | 80 | firstch = w.substr(0,1); 81 | if (firstch == "y") 82 | w = firstch.toUpperCase() + w.substr(1); 83 | 84 | // Step 1a 85 | re = /^(.+?)(ss|i)es$/; 86 | re2 = /^(.+?)([^s])s$/; 87 | 88 | if (re.test(w)) 89 | w = w.replace(re,"$1$2"); 90 | else if (re2.test(w)) 91 | w = w.replace(re2,"$1$2"); 92 | 93 | // Step 1b 94 | re = /^(.+?)eed$/; 95 | re2 = /^(.+?)(ed|ing)$/; 96 | if (re.test(w)) { 97 | var fp = re.exec(w); 98 | re = new RegExp(mgr0); 99 | if (re.test(fp[1])) { 100 | re = /.$/; 101 | w = w.replace(re,""); 102 | } 103 | } 104 | else if (re2.test(w)) { 105 | var fp = re2.exec(w); 106 | stem = fp[1]; 107 | re2 = new RegExp(s_v); 108 | if (re2.test(stem)) { 109 | w = stem; 110 | re2 = /(at|bl|iz)$/; 111 | re3 = new RegExp("([^aeiouylsz])\\1$"); 112 | re4 = new RegExp("^" + C + v + "[^aeiouwxy]$"); 113 | if (re2.test(w)) 114 | w = w + "e"; 115 | else if (re3.test(w)) { 116 | re = /.$/; 117 | w = w.replace(re,""); 118 | } 119 | else if (re4.test(w)) 120 | w = w + "e"; 121 | } 122 | } 123 | 124 | // Step 1c 125 | re = /^(.+?)y$/; 126 | if (re.test(w)) { 127 | var fp = re.exec(w); 128 | stem = fp[1]; 129 | re = new RegExp(s_v); 130 | if (re.test(stem)) 131 | w = stem + "i"; 132 | } 133 | 134 | // Step 2 135 | re = /^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/; 136 | if (re.test(w)) { 137 | var fp = re.exec(w); 138 | stem = fp[1]; 139 | suffix = fp[2]; 140 | re = new RegExp(mgr0); 141 | if (re.test(stem)) 142 | w = stem + step2list[suffix]; 143 | } 144 | 145 | // Step 3 146 | re = /^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/; 147 | if (re.test(w)) { 148 | var fp = re.exec(w); 149 | stem = fp[1]; 150 | suffix = fp[2]; 151 | re = new RegExp(mgr0); 152 | if (re.test(stem)) 153 | w = stem + step3list[suffix]; 154 | } 155 | 156 | // Step 4 157 | re = /^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/; 158 | re2 = /^(.+?)(s|t)(ion)$/; 159 | if (re.test(w)) { 160 | var fp = re.exec(w); 161 | stem = fp[1]; 162 | re = new RegExp(mgr1); 163 | if (re.test(stem)) 164 | w = stem; 165 | } 166 | else if (re2.test(w)) { 167 | var fp = re2.exec(w); 168 | stem = fp[1] + fp[2]; 169 | re2 = new RegExp(mgr1); 170 | if (re2.test(stem)) 171 | w = stem; 172 | } 173 | 174 | // Step 5 175 | re = /^(.+?)e$/; 176 | if (re.test(w)) { 177 | var fp = re.exec(w); 178 | stem = fp[1]; 179 | re = new RegExp(mgr1); 180 | re2 = new RegExp(meq1); 181 | re3 = new RegExp("^" + C + v + "[^aeiouwxy]$"); 182 | if (re.test(stem) || (re2.test(stem) && !(re3.test(stem)))) 183 | w = stem; 184 | } 185 | re = /ll$/; 186 | re2 = new RegExp(mgr1); 187 | if (re.test(w) && re2.test(w)) { 188 | re = /.$/; 189 | w = w.replace(re,""); 190 | } 191 | 192 | // and turn initial Y back to y 193 | if (firstch == "y") 194 | w = firstch.toLowerCase() + w.substr(1); 195 | return w; 196 | } 197 | } 198 | 199 | 200 | 201 | 202 | 203 | var splitChars = (function() { 204 | var result = {}; 205 | var singles = [96, 180, 187, 191, 215, 247, 749, 885, 903, 907, 909, 930, 1014, 1648, 206 | 1748, 1809, 2416, 2473, 2481, 2526, 2601, 2609, 2612, 2615, 2653, 2702, 207 | 2706, 2729, 2737, 2740, 2857, 2865, 2868, 2910, 2928, 2948, 2961, 2971, 208 | 2973, 3085, 3089, 3113, 3124, 3213, 3217, 3241, 3252, 3295, 3341, 3345, 209 | 3369, 3506, 3516, 3633, 3715, 3721, 3736, 3744, 3748, 3750, 3756, 3761, 210 | 3781, 3912, 4239, 4347, 4681, 4695, 4697, 4745, 4785, 4799, 4801, 4823, 211 | 4881, 5760, 5901, 5997, 6313, 7405, 8024, 8026, 8028, 8030, 8117, 8125, 212 | 8133, 8181, 8468, 8485, 8487, 8489, 8494, 8527, 11311, 11359, 11687, 11695, 213 | 11703, 11711, 11719, 11727, 11735, 12448, 12539, 43010, 43014, 43019, 43587, 214 | 43696, 43713, 64286, 64297, 64311, 64317, 64319, 64322, 64325, 65141]; 215 | var i, j, start, end; 216 | for (i = 0; i < singles.length; i++) { 217 | result[singles[i]] = true; 218 | } 219 | var ranges = [[0, 47], [58, 64], [91, 94], [123, 169], [171, 177], [182, 184], [706, 709], 220 | [722, 735], [741, 747], [751, 879], [888, 889], [894, 901], [1154, 1161], 221 | [1318, 1328], [1367, 1368], [1370, 1376], [1416, 1487], [1515, 1519], [1523, 1568], 222 | [1611, 1631], [1642, 1645], [1750, 1764], [1767, 1773], [1789, 1790], [1792, 1807], 223 | [1840, 1868], [1958, 1968], [1970, 1983], [2027, 2035], [2038, 2041], [2043, 2047], 224 | [2070, 2073], [2075, 2083], [2085, 2087], [2089, 2307], [2362, 2364], [2366, 2383], 225 | [2385, 2391], [2402, 2405], [2419, 2424], [2432, 2436], [2445, 2446], [2449, 2450], 226 | [2483, 2485], [2490, 2492], [2494, 2509], [2511, 2523], [2530, 2533], [2546, 2547], 227 | [2554, 2564], [2571, 2574], [2577, 2578], [2618, 2648], [2655, 2661], [2672, 2673], 228 | [2677, 2692], [2746, 2748], [2750, 2767], [2769, 2783], [2786, 2789], [2800, 2820], 229 | [2829, 2830], [2833, 2834], [2874, 2876], [2878, 2907], [2914, 2917], [2930, 2946], 230 | [2955, 2957], [2966, 2968], [2976, 2978], [2981, 2983], [2987, 2989], [3002, 3023], 231 | [3025, 3045], [3059, 3076], [3130, 3132], [3134, 3159], [3162, 3167], [3170, 3173], 232 | [3184, 3191], [3199, 3204], [3258, 3260], [3262, 3293], [3298, 3301], [3312, 3332], 233 | [3386, 3388], [3390, 3423], [3426, 3429], [3446, 3449], [3456, 3460], [3479, 3481], 234 | [3518, 3519], [3527, 3584], [3636, 3647], [3655, 3663], [3674, 3712], [3717, 3718], 235 | [3723, 3724], [3726, 3731], [3752, 3753], [3764, 3772], [3774, 3775], [3783, 3791], 236 | [3802, 3803], [3806, 3839], [3841, 3871], [3892, 3903], [3949, 3975], [3980, 4095], 237 | [4139, 4158], [4170, 4175], [4182, 4185], [4190, 4192], [4194, 4196], [4199, 4205], 238 | [4209, 4212], [4226, 4237], [4250, 4255], [4294, 4303], [4349, 4351], [4686, 4687], 239 | [4702, 4703], [4750, 4751], [4790, 4791], [4806, 4807], [4886, 4887], [4955, 4968], 240 | [4989, 4991], [5008, 5023], [5109, 5120], [5741, 5742], [5787, 5791], [5867, 5869], 241 | [5873, 5887], [5906, 5919], [5938, 5951], [5970, 5983], [6001, 6015], [6068, 6102], 242 | [6104, 6107], [6109, 6111], [6122, 6127], [6138, 6159], [6170, 6175], [6264, 6271], 243 | [6315, 6319], [6390, 6399], [6429, 6469], [6510, 6511], [6517, 6527], [6572, 6592], 244 | [6600, 6607], [6619, 6655], [6679, 6687], [6741, 6783], [6794, 6799], [6810, 6822], 245 | [6824, 6916], [6964, 6980], [6988, 6991], [7002, 7042], [7073, 7085], [7098, 7167], 246 | [7204, 7231], [7242, 7244], [7294, 7400], [7410, 7423], [7616, 7679], [7958, 7959], 247 | [7966, 7967], [8006, 8007], [8014, 8015], [8062, 8063], [8127, 8129], [8141, 8143], 248 | [8148, 8149], [8156, 8159], [8173, 8177], [8189, 8303], [8306, 8307], [8314, 8318], 249 | [8330, 8335], [8341, 8449], [8451, 8454], [8456, 8457], [8470, 8472], [8478, 8483], 250 | [8506, 8507], [8512, 8516], [8522, 8525], [8586, 9311], [9372, 9449], [9472, 10101], 251 | [10132, 11263], [11493, 11498], [11503, 11516], [11518, 11519], [11558, 11567], 252 | [11622, 11630], [11632, 11647], [11671, 11679], [11743, 11822], [11824, 12292], 253 | [12296, 12320], [12330, 12336], [12342, 12343], [12349, 12352], [12439, 12444], 254 | [12544, 12548], [12590, 12592], [12687, 12689], [12694, 12703], [12728, 12783], 255 | [12800, 12831], [12842, 12880], [12896, 12927], [12938, 12976], [12992, 13311], 256 | [19894, 19967], [40908, 40959], [42125, 42191], [42238, 42239], [42509, 42511], 257 | [42540, 42559], [42592, 42593], [42607, 42622], [42648, 42655], [42736, 42774], 258 | [42784, 42785], [42889, 42890], [42893, 43002], [43043, 43055], [43062, 43071], 259 | [43124, 43137], [43188, 43215], [43226, 43249], [43256, 43258], [43260, 43263], 260 | [43302, 43311], [43335, 43359], [43389, 43395], [43443, 43470], [43482, 43519], 261 | [43561, 43583], [43596, 43599], [43610, 43615], [43639, 43641], [43643, 43647], 262 | [43698, 43700], [43703, 43704], [43710, 43711], [43715, 43738], [43742, 43967], 263 | [44003, 44015], [44026, 44031], [55204, 55215], [55239, 55242], [55292, 55295], 264 | [57344, 63743], [64046, 64047], [64110, 64111], [64218, 64255], [64263, 64274], 265 | [64280, 64284], [64434, 64466], [64830, 64847], [64912, 64913], [64968, 65007], 266 | [65020, 65135], [65277, 65295], [65306, 65312], [65339, 65344], [65371, 65381], 267 | [65471, 65473], [65480, 65481], [65488, 65489], [65496, 65497]]; 268 | for (i = 0; i < ranges.length; i++) { 269 | start = ranges[i][0]; 270 | end = ranges[i][1]; 271 | for (j = start; j <= end; j++) { 272 | result[j] = true; 273 | } 274 | } 275 | return result; 276 | })(); 277 | 278 | function splitQuery(query) { 279 | var result = []; 280 | var start = -1; 281 | for (var i = 0; i < query.length; i++) { 282 | if (splitChars[query.charCodeAt(i)]) { 283 | if (start !== -1) { 284 | result.push(query.slice(start, i)); 285 | start = -1; 286 | } 287 | } else if (start === -1) { 288 | start = i; 289 | } 290 | } 291 | if (start !== -1) { 292 | result.push(query.slice(start)); 293 | } 294 | return result; 295 | } 296 | 297 | 298 | -------------------------------------------------------------------------------- /docs/build/html/genindex.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Index — Bigraph Documentation 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 |
49 | 50 | 99 | 100 |
101 | 102 | 103 | 109 | 110 | 111 |
112 | 113 | 405 |
406 | 407 |
408 | 409 |
410 | 411 | 412 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | -------------------------------------------------------------------------------- /bigraph/bigraph.py: -------------------------------------------------------------------------------- 1 | import collections 2 | import operator 3 | import pathlib 4 | import time 5 | 6 | import networkx as nx 7 | import tabulate 8 | 9 | from bigraph.preprocessing import ImportFiles 10 | from .algorithms import Algorithms 11 | from .preprocessing import GetAdjacents 12 | from .preprocessing import MakeGraph 13 | 14 | 15 | class BiGraph(Algorithms, ImportFiles, MakeGraph, GetAdjacents): 16 | def __init__(self): 17 | df, df_nodes = self.import_files() 18 | self.graph = self.make_graph(df) 19 | 20 | print(self.graph.__dict__) 21 | snp = len({n for n, d in self.graph.nodes(data=True) if d["bipartite"] == 0}) 22 | cancer = len({n for n, d in self.graph.nodes(data=True) if d["bipartite"] == 1}) 23 | headers = ["Number of nodes", "Number of edges", "SNP", "Cancer"] 24 | table = [[self.graph.nodes.__len__(), self.graph.edges.__len__(), snp, cancer]] 25 | print(tabulate.tabulate(table, headers, tablefmt="fancy_grid")) 26 | print(nx.number_connected_components(self.graph)) 27 | 28 | def jc_predict(self) -> dict: 29 | """ 30 | Compute the Jaccard-Needham dissimilarity between two 1-D arrays. 31 | 32 | :return: A dictionary containing the Jaccard distance between vectors `left_element` and `right_element`. 33 | """ 34 | start_jc = time.time() 35 | 36 | dictionary = {} 37 | pathlib.Path("./predictions").mkdir(parents=True, exist_ok=True) 38 | 39 | out = open("./predictions/jaccard.csv", "w") 40 | hop2s = dict() 41 | neighbors = dict() 42 | jaccard_sim = collections.defaultdict(dict) 43 | left_set = [n for n, d in self.graph.nodes(data=True) if d["bipartite"] == 0] 44 | right_set = [n for n, d in self.graph.nodes(data=True) if d["bipartite"] == 1] 45 | 46 | out.write("(left_element, right_element)") 47 | out.write(",") 48 | out.write("Score") 49 | out.write("\n") 50 | 51 | exception_count = 0 52 | for left_element in left_set: 53 | hop2s[left_element] = self._get_hop_2_neighbours( 54 | self.graph, list(set(self.graph[left_element])), 1 55 | ) 56 | for right_element in right_set: 57 | neighbors[right_element] = list(set(self.graph[right_element])) 58 | if not (left_element, right_element) in self.graph.edges: 59 | try: 60 | jaccard_sim[left_element][right_element] = self.jaccard( 61 | hop2s[(left_element)], neighbors[(right_element)] 62 | ) 63 | if jaccard_sim[left_element][right_element] > 0: 64 | dictionary.update( 65 | { 66 | (left_element, right_element): jaccard_sim[ 67 | left_element 68 | ][right_element] 69 | } 70 | ) 71 | except: 72 | exception_count += 1 73 | print(exception_count) 74 | for k, v in sorted( 75 | dictionary.items(), key=operator.itemgetter(1), reverse=True 76 | ): 77 | out.write(str((k[0], k[1]))) 78 | out.write(",") 79 | out.write(str(jaccard_sim[k[0]][k[1]])) 80 | out.write("\n") 81 | 82 | _time = time.time() - start_jc 83 | print("Jaccard Executed in {} seconds".format(_time), "\n") 84 | 85 | return dictionary 86 | 87 | def aa_predict(self) -> dict: 88 | """ 89 | Compute the Jaccard-Needham dissimilarity between two 1-D arrays. 90 | 91 | :return: A dictionary containing the Adamic-adar score for `left_element` and `right_element`. 92 | """ 93 | start_aa = time.time() 94 | 95 | print("Adamic_adar prediction starting...") 96 | pathlib.Path("./predictions").mkdir(parents=True, exist_ok=True) 97 | 98 | out = open("./predictions/adamic_adar.csv", "w") 99 | outN = open("./predictions/adamic_adar_with_name.csv", "w") 100 | hop2s = dict() 101 | neighbors = dict() 102 | aa_sim = collections.defaultdict(dict) 103 | sortDic = {} 104 | left_set = [n for n, d in self.graph.nodes(data=True) if d["bipartite"] == 0] 105 | right_set = [n for n, d in self.graph.nodes(data=True) if d["bipartite"] == 1] 106 | dictionary = {} 107 | 108 | out.write("(left_element, right_element)") 109 | out.write(",") 110 | out.write("Score") 111 | out.write("\n") 112 | 113 | exception_count = 0 114 | for left_element in left_set: 115 | hop2s[left_element] = self._get_hop_2_neighbours( 116 | self.graph, list(set(self.graph[left_element])), 1 117 | ) 118 | for right_element in right_set: 119 | neighbors[right_element] = list(set(self.graph[right_element])) 120 | if not (left_element, right_element) in self.graph.edges: 121 | try: 122 | aa_sim[left_element][right_element] = self.adamic_adar( 123 | hop2s[(left_element)], 124 | neighbors[(right_element)], 125 | self.graph, 126 | ) 127 | if aa_sim[left_element][right_element] > 0: 128 | dictionary.update( 129 | { 130 | (left_element, right_element): aa_sim[left_element][ 131 | right_element 132 | ] 133 | } 134 | ) 135 | except: 136 | exception_count += 1 137 | print(exception_count) 138 | 139 | for k, v in sorted( 140 | dictionary.items(), key=operator.itemgetter(1), reverse=True 141 | ): 142 | out.write(str((k[0], k[1]))) 143 | out.write(",") 144 | out.write(str(aa_sim[k[0]][k[1]])) 145 | out.write("\n") 146 | 147 | _time = time.time() - start_aa 148 | print("Adamic-adar Executed in {} seconds".format(_time), "\n") 149 | return dictionary 150 | 151 | def cn_predict(self) -> dict: 152 | """ 153 | Return the common neighbors of two nodes in a graph. 154 | 155 | :return: A dictionary containing the Common neighbours score for `left_element` and `right_element`. 156 | """ 157 | start_cn = time.time() 158 | 159 | pathlib.Path("./predictions").mkdir(parents=True, exist_ok=True) 160 | 161 | out = open("./predictions/common_neighbor.csv", "w") 162 | hop2s = dict() 163 | neighbors = dict() 164 | cn_sim = collections.defaultdict(dict) 165 | sortDic = {} 166 | 167 | left_set = [n for n, d in self.graph.nodes(data=True) if d["bipartite"] == 0] 168 | right_set = [n for n, d in self.graph.nodes(data=True) if d["bipartite"] == 1] 169 | 170 | dictionary = {} 171 | out.write("(left_element, right_element)") 172 | out.write(",") 173 | out.write("Score") 174 | out.write("\n") 175 | 176 | for left_element in left_set: 177 | hop2s[left_element] = self._get_hop_2_neighbours( 178 | self.graph, list(set(self.graph[left_element])), 1 179 | ) 180 | for right_element in right_set: 181 | # print('cancer {} -- '.format(len(G[right_element]))) 182 | neighbors[right_element] = list(set(self.graph[right_element])) 183 | if not (left_element, right_element) in self.graph.edges: 184 | cn_sim[left_element][right_element] = self.common_neighbors( 185 | hop2s[left_element], neighbors[right_element] 186 | ) 187 | 188 | if cn_sim[left_element][right_element] > 0: 189 | dictionary.update( 190 | { 191 | (left_element, right_element): cn_sim[left_element][ 192 | right_element 193 | ] 194 | } 195 | ) 196 | 197 | for k, v in sorted( 198 | dictionary.items(), key=operator.itemgetter(1), reverse=True 199 | ): 200 | # print(k[0],v) 201 | out.write(str((k[0], k[1]))) 202 | out.write(",") 203 | out.write(str(cn_sim[k[0]][k[1]])) 204 | out.write("\n") 205 | 206 | _time = time.time() - start_cn 207 | print("Common neighbours Executed in {} seconds".format(_time), "\n") 208 | 209 | return dictionary 210 | 211 | def pa_predict(self) -> dict: 212 | """ 213 | Compute the preferential attachment score of all node pairs. 214 | 215 | :return: A dictionary containing the Preferential attachment score for `left_element` and `right_element`. 216 | """ 217 | start_pa = time.time() 218 | # print('Preferential_attachment prediction starting...') 219 | dictionary = {} 220 | 221 | pathlib.Path("./predictions").mkdir(parents=True, exist_ok=True) 222 | out = open("./predictions/preferential_attachment.csv", "w") 223 | hop2s = dict() 224 | neighbors_right_element = dict() 225 | neighbors_left_element = dict() 226 | pa_sim = collections.defaultdict(dict) 227 | sortDic = {} 228 | left_set = [n for n, d in self.graph.nodes(data=True) if d["bipartite"] == 0] 229 | right_set = [n for n, d in self.graph.nodes(data=True) if d["bipartite"] == 1] 230 | 231 | out.write("(left_element, right_element)") 232 | out.write(",") 233 | out.write("Score") 234 | out.write("\n") 235 | 236 | for left_element in left_set: 237 | neighbors_left_element[left_element] = list(set(self.graph[left_element])) 238 | for right_element in right_set: 239 | neighbors_right_element[right_element] = list( 240 | set(self.graph[right_element]) 241 | ) 242 | if not (left_element, right_element) in self.graph.edges: 243 | pa_sim[left_element][right_element] = self.preferential_attachment( 244 | neighbors_left_element[(left_element)], 245 | neighbors_right_element[(right_element)], 246 | ) 247 | if pa_sim[left_element][right_element] > 0: 248 | dictionary.update( 249 | { 250 | (left_element, right_element): pa_sim[left_element][ 251 | right_element 252 | ] 253 | } 254 | ) 255 | 256 | for k, v in sorted( 257 | dictionary.items(), key=operator.itemgetter(1), reverse=True 258 | ): 259 | out.write(str((k[0], k[1]))) 260 | out.write(",") 261 | out.write(str(pa_sim[k[0]][k[1]])) 262 | out.write("\n") 263 | 264 | _time = time.time() - start_pa 265 | print("Preferential attachment Executed in {} seconds".format(_time), "\n") 266 | 267 | return dictionary 268 | 269 | def katz_predict(self, df_nodes: dict) -> dict: 270 | """ 271 | Compute the Katz similarity score of all node pairs. 272 | 273 | :param df_nodes: Graph nodes 274 | :return: A dictionary containing the Preferential attachment score for `left_element` and `right_element`. 275 | """ 276 | start_katz = time.time() 277 | 278 | pathlib.Path("./predictions").mkdir(parents=True, exist_ok=True) 279 | 280 | out = open("./predictions/preferential_attachment.csv", "w") 281 | outN = open("./predictions/preferential_attachment_with_name.csv", "w") 282 | hop2s = dict() 283 | neighbors = dict() 284 | katz_sim = collections.defaultdict(dict) 285 | sortDic = {} 286 | left_set = list(set(nx.bipartite.sets(self.graph)[0])) 287 | right_set = list(set(nx.bipartite.sets(self.graph)[1])) 288 | 289 | out.write("(left_element, right_element)") 290 | out.write(",") 291 | out.write("Score") 292 | out.write("\n") 293 | 294 | outN.write("(left_element, right_element)") 295 | outN.write(",") 296 | outN.write("Score") 297 | outN.write("\n") 298 | 299 | for left_element in left_set: 300 | hop2s[left_element] = self._get_hop_2_neighbours( 301 | self.graph, list(set(self.graph[left_element])), 1 302 | ) 303 | for right_element in right_set: 304 | neighbors[right_element] = list(set(self.graph[right_element])) 305 | if not (left_element, right_element) in self.graph.edges: 306 | katz_sim[left_element][right_element] = self.katz_similarity( 307 | int(left_element), int(right_element), self.graph 308 | ) 309 | if katz_sim[left_element][right_element] > 0: 310 | out.write(str((left_element, right_element))) 311 | out.write(",") 312 | out.write(str(katz_sim[left_element][right_element])) 313 | out.write("\n") 314 | 315 | outN.write( 316 | str((df_nodes[left_element], df_nodes[right_element])) 317 | ) 318 | outN.write(",") 319 | outN.write(str(katz_sim[left_element][right_element])) 320 | outN.write("\n") 321 | 322 | _time = time.time() - start_katz 323 | print("Katz similarity Executed in {} seconds".format(_time), "\n") 324 | --------------------------------------------------------------------------------