# DEMON - Overlapping Community Discovery.
[![Test and Coverage (Ubuntu)](https://github.com/GiulioRossetti/DEMON/actions/workflows/test_ubuntu.yml/badge.svg)](https://github.com/GiulioRossetti/DEMON/actions/workflows/test_ubuntu.yml)
[![Coverage Status](https://coveralls.io/repos/github/GiulioRossetti/DEMON/badge.svg?branch=master)](https://coveralls.io/github/GiulioRossetti/DEMON?branch=master)
[![pyversions](https://img.shields.io/pypi/pyversions/demon.svg)](https://badge.fury.io/py/DEMON)
[![PyPI version](https://badge.fury.io/py/demon.svg)](https://badge.fury.io/py/DEMON)
[![Updates](https://pyup.io/repos/github/GiulioRossetti/DEMON/shield.svg)](https://pyup.io/repos/github/GiulioRossetti/DEMON/)
[![DOI](https://zenodo.org/badge/53486170.svg)](https://zenodo.org/badge/latestdoi/53486170)
[![PyPI download month](https://img.shields.io/pypi/dm/demon.svg?color=blue&style=plastic)](https://pypi.python.org/pypi/demon/)
![DEMON logo](http://www.giuliorossetti.net/about/wp-content/uploads/2013/07/Demon-300x233.png)
Community discovery in complex networks is an interesting problem with a number of applications, especially in the knowledge extraction task in social and information networks. However, many large networks often lack a particular community organization at a global level. In these cases, traditional graph partitioning algorithms fail to let the latent knowledge embedded in modular structure emerge, because they impose a top-down global view of a network. We propose here a simple local-first approach to community discovery, able to unveil the modular organization of real complex networks. This is achieved by democratically letting each node vote for the communities it sees surrounding it in its limited view of the global system, i.e. its ego neighborhood, using a label propagation algorithm; finally, the local communities are merged into a global collection.
**Note:** Demon has been integrated within [CDlib](http://cdlib.readthedocs.io) a python package dedicated to community detection algorithms, check it out!
## Citation
If you use our algorithm please cite the following works:
>Coscia, Michele; Rossetti, Giulio; Giannotti, Fosca; Pedreschi, Dino
> ["Uncovering Hierarchical and Overlapping Communities with a Local-First Approach"](http://dl.acm.org/citation.cfm?id=2629511)
>ACM Transactions on Knowledge Discovery from Data (TKDD), 9 (1), 2014.
>Coscia, Michele; Rossetti, Giulio; Giannotti, Fosca; Pedreschi, Dino
> ["DEMON: a Local-First Discovery Method for Overlapping Communities"](http://dl.acm.org/citation.cfm?id=2339630)
>SIGKDD international conference on knowledge discovery and data mining, pp. 615-623, IEEE ACM, 2012, ISBN: 978-1-4503-1462-6.
## Installation
In order to install the package just download (or clone) the current project and copy the demon folder in the root of your application.
Alternatively use pip:
```bash
pip install demon
```
or conda
```bash
conda install -c giuliorossetti demon
```
Demon is written in python and requires the following package to run:
- networkx
- tqdm
## Implementation details
# Execution
The algorithm can be used as standalone program as well as integrated in python scripts.
## Standalone
```bash
python demon filename epsilon -c min_com_size
```
where:
* *filename*: edgelist filename
* *epsilon*: merging threshold in [0,1]
* *min_community_size*: minimum size for communities (default 3 - optional)
Demon results will be saved on a text file.
### Input file specs
Edgelist format: tab separated edgelist (nodes represented with integer ids).
Row example:
```
node_id0 node_id1
```
## As python library
Demon can be executed specifying as input:
1. an edgelist file
```python
import demon as d
dm = d.Demon(network_filename="filename.tsc", epsilon=0.25, min_community_size=3, file_output="communities.txt")
dm.execute()
```
2. a *networkx* Graph object
```python
import networkx as nx
import demon as d
g = nx.karate_club_graph()
dm = d.Demon(graph=g, epsilon=0.25, min_community_size=3)
coms = dm.execute()
```
The parameter *file_output*, if specified, allows to write on file the algorithm results.
Conversely, the communities will be returned to the main program as a list of node ids tuple, e.g.,
```python
[(0,1,2),(3,4),(5,6,7)]
```
Raw data
{
"_id": null,
"home_page": "https://github.com/GiulioRossetti/DEMON",
"name": "demon",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "complex-networks,community discovery",
"author": "Giulio Rossetti",
"author_email": "giulio.rossetti@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/49/01/21337857631a97ab551bb2e3b5691ed6b1b9586011aa6a5355b9694a37fa/demon-2.0.6.tar.gz",
"platform": "",
"description": "# DEMON - Overlapping Community Discovery.\n\n[![Test and Coverage (Ubuntu)](https://github.com/GiulioRossetti/DEMON/actions/workflows/test_ubuntu.yml/badge.svg)](https://github.com/GiulioRossetti/DEMON/actions/workflows/test_ubuntu.yml)\n[![Coverage Status](https://coveralls.io/repos/github/GiulioRossetti/DEMON/badge.svg?branch=master)](https://coveralls.io/github/GiulioRossetti/DEMON?branch=master)\n[![pyversions](https://img.shields.io/pypi/pyversions/demon.svg)](https://badge.fury.io/py/DEMON)\n[![PyPI version](https://badge.fury.io/py/demon.svg)](https://badge.fury.io/py/DEMON)\n[![Updates](https://pyup.io/repos/github/GiulioRossetti/DEMON/shield.svg)](https://pyup.io/repos/github/GiulioRossetti/DEMON/)\n[![DOI](https://zenodo.org/badge/53486170.svg)](https://zenodo.org/badge/latestdoi/53486170)\n[![PyPI download month](https://img.shields.io/pypi/dm/demon.svg?color=blue&style=plastic)](https://pypi.python.org/pypi/demon/)\n\n![DEMON logo](http://www.giuliorossetti.net/about/wp-content/uploads/2013/07/Demon-300x233.png)\n\n\nCommunity discovery in complex networks is an interesting problem with a number of applications, especially in the knowledge extraction task in social and information networks. However, many large networks often lack a particular community organization at a global level. In these cases, traditional graph partitioning algorithms fail to let the latent knowledge embedded in modular structure emerge, because they impose a top-down global view of a network. We propose here a simple local-first approach to community discovery, able to unveil the modular organization of real complex networks. This is achieved by democratically letting each node vote for the communities it sees surrounding it in its limited view of the global system, i.e. its ego neighborhood, using a label propagation algorithm; finally, the local communities are merged into a global collection. \n\n**Note:** Demon has been integrated within [CDlib](http://cdlib.readthedocs.io) a python package dedicated to community detection algorithms, check it out!\n\n## Citation\nIf you use our algorithm please cite the following works:\n\n>Coscia, Michele; Rossetti, Giulio; Giannotti, Fosca; Pedreschi, Dino\n> [\"Uncovering Hierarchical and Overlapping Communities with a Local-First Approach\"](http://dl.acm.org/citation.cfm?id=2629511)\n>ACM Transactions on Knowledge Discovery from Data (TKDD), 9 (1), 2014. \n\n>Coscia, Michele; Rossetti, Giulio; Giannotti, Fosca; Pedreschi, Dino\n> [\"DEMON: a Local-First Discovery Method for Overlapping Communities\"](http://dl.acm.org/citation.cfm?id=2339630)\n>SIGKDD international conference on knowledge discovery and data mining, pp. 615-623, IEEE ACM, 2012, ISBN: 978-1-4503-1462-6.\n\n## Installation\n\n\nIn order to install the package just download (or clone) the current project and copy the demon folder in the root of your application.\n\nAlternatively use pip:\n```bash\npip install demon\n```\n\nor conda\n```bash\nconda install -c giuliorossetti demon\n```\n\nDemon is written in python and requires the following package to run:\n- networkx\n- tqdm\n\n## Implementation details\n\n\n\n# Execution\n\nThe algorithm can be used as standalone program as well as integrated in python scripts.\n\n## Standalone\n\n```bash\n\npython demon filename epsilon -c min_com_size\n```\n\nwhere:\n* *filename*: edgelist filename\n* *epsilon*: merging threshold in [0,1]\n* *min_community_size*: minimum size for communities (default 3 - optional)\n\nDemon results will be saved on a text file.\n\n### Input file specs \nEdgelist format: tab separated edgelist (nodes represented with integer ids).\n\nRow example:\n```\nnode_id0 node_id1\n```\n\n## As python library\n\nDemon can be executed specifying as input: \n\n1. an edgelist file\n\n```python\nimport demon as d\ndm = d.Demon(network_filename=\"filename.tsc\", epsilon=0.25, min_community_size=3, file_output=\"communities.txt\")\ndm.execute()\n\n```\n\n2. a *networkx* Graph object\n\n```python\nimport networkx as nx\nimport demon as d\n\ng = nx.karate_club_graph()\ndm = d.Demon(graph=g, epsilon=0.25, min_community_size=3)\ncoms = dm.execute()\n\n```\n\nThe parameter *file_output*, if specified, allows to write on file the algorithm results.\nConversely, the communities will be returned to the main program as a list of node ids tuple, e.g.,\n\n```python\n[(0,1,2),(3,4),(5,6,7)]\n```\n\n\n",
"bugtrack_url": null,
"license": "BSD-2-Clause",
"summary": "Community Discovery algorithm",
"version": "2.0.6",
"project_urls": {
"Homepage": "https://github.com/GiulioRossetti/DEMON"
},
"split_keywords": [
"complex-networks",
"community discovery"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "96855f9146e3f8d7324d8741cd3bea9b99926d5ee75571b9610c661b1bbd06f5",
"md5": "3cd793135244c9e6d9082f9e8d225ebe",
"sha256": "2dc023c9d2a8550a4039c4c46f02153c467a7ccce9144e38a1ea0d5b0054e362"
},
"downloads": -1,
"filename": "demon-2.0.6-py3-none-any.whl",
"has_sig": false,
"md5_digest": "3cd793135244c9e6d9082f9e8d225ebe",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 7342,
"upload_time": "2021-06-23T09:11:20",
"upload_time_iso_8601": "2021-06-23T09:11:20.236061Z",
"url": "https://files.pythonhosted.org/packages/96/85/5f9146e3f8d7324d8741cd3bea9b99926d5ee75571b9610c661b1bbd06f5/demon-2.0.6-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "490121337857631a97ab551bb2e3b5691ed6b1b9586011aa6a5355b9694a37fa",
"md5": "8ab3e681d9e5c643ab1fb6d7c8558679",
"sha256": "60e5d85aaf039172770e58bb4e989287b672d8008a83d66b8e722c273d38a359"
},
"downloads": -1,
"filename": "demon-2.0.6.tar.gz",
"has_sig": false,
"md5_digest": "8ab3e681d9e5c643ab1fb6d7c8558679",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 7589,
"upload_time": "2021-06-23T09:11:21",
"upload_time_iso_8601": "2021-06-23T09:11:21.126067Z",
"url": "https://files.pythonhosted.org/packages/49/01/21337857631a97ab551bb2e3b5691ed6b1b9586011aa6a5355b9694a37fa/demon-2.0.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2021-06-23 09:11:21",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "GiulioRossetti",
"github_project": "DEMON",
"travis_ci": true,
"coveralls": true,
"github_actions": true,
"requirements": [
{
"name": "tqdm",
"specs": []
},
{
"name": "networkx",
"specs": [
[
">=",
"2.4"
]
]
}
],
"lcname": "demon"
}