# Community-Detection-Modularity
Eigenvector-based community detection is a method used to identify communities or groups within a network by analyzing the eigenvectors of the network's adjacency matrix. The basic idea behind this approach is that nodes that belong to the same community will be more strongly connected to each other than to nodes in other communities.
The method starts by calculating the adjacency matrix of the network, which represents the connections between nodes. Next, the eigenvalues and eigenvectors of this matrix are calculated. The eigenvectors with the largest eigenvalues are then used to assign nodes to communities.
The basic idea is that nodes that belong to the same community will have similar eigenvector values for these dominant eigenvectors. By grouping nodes with similar eigenvector values together, communities can be identified.
The method starts by calculating the adjacency matrix of the network, which represents the connections between nodes. Next, the eigenvalues and eigenvectors of this matrix are calculated. The eigenvectors with the largest eigenvalues are then used to assign nodes to communities.
The basic idea is that nodes that belong to the same community will have similar eigenvector values for these dominant eigenvectors. By grouping nodes with similar eigenvector values together, communities can be identified.
## Installation
### Install via PIP
```cmd
pip install age-cda
```
### Build from Source
```cmd
sudo apt-get update
sudo apt-get install libeigen3-dev
git clone https://github.com/Munmud/Community-Detection-Modularity
cd Community-Detection-Modularity
python setup.py install
```
- [Configure GSL - GNU Scientific Library](https://solarianprogrammer.com/2020/01/26/getting-started-gsl-gnu-scientific-library-windows-macos-linux/)
### Unit Test
```cmd
python -m unittest test_community.py
```
## Instruction
### import
```py
from age_cda import Graph
```
### Create Graph
```py
nodes = [0, 1, 2, 3, 4, 5]
edges = [[0, 1], [0, 2], [1, 2], [2, 3], [3, 4], [3, 5], [4, 5]]
g = Graph.Graph()
g.createGraph(nodes, edges)
```
- Nodes : `any`
- Edges :
- `2d array : adjacency list`
- `Each element within Nodes array
### Generate Community Assignment
```py
res = g.get_community()
```
### Output Format
```
[[3,4,5],[0,1,2]]
```
- List community
- Each community has list of nodes
### Samples
- [Creating Graph](https://github.com/Munmud/Community-Detection-Modularity/blob/main/Samples/sample1.py)
- [Zachary's karate club](https://github.com/Munmud/Community-Detection-Modularity/blob/main/Samples/sample2.py)
### Reference
- [Finding community structure in networks using the eigenvectors of matrices](https://arxiv.org/pdf/physics/0605087.pdf)
- [Modularity and community structure in networks](https://www.pnas.org/doi/10.1073/pnas.0601602103)
- [Statistical Mechanics of Community Detection](https://ia903002.us.archive.org/33/items/arxiv-cond-mat0603718/cond-mat0603718.pdf)
Raw data
{
"_id": null,
"home_page": "https://github.com/Munmud/Community-Detection-Modularity",
"name": "age-cda",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": "",
"keywords": "Community-Detection,Modularity,Reichardt and Bornholdt,Newman,partition network,k means cluster",
"author": "Moontasir Mahmood",
"author_email": "moontasir042@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/df/b6/64039580f630f5233932d1b7fde297705a983050fc5d8d6a3e2e009fd721/age_cda-0.0.4.tar.gz",
"platform": null,
"description": "# Community-Detection-Modularity\n\nEigenvector-based community detection is a method used to identify communities or groups within a network by analyzing the eigenvectors of the network's adjacency matrix. The basic idea behind this approach is that nodes that belong to the same community will be more strongly connected to each other than to nodes in other communities.\n\nThe method starts by calculating the adjacency matrix of the network, which represents the connections between nodes. Next, the eigenvalues and eigenvectors of this matrix are calculated. The eigenvectors with the largest eigenvalues are then used to assign nodes to communities.\n\nThe basic idea is that nodes that belong to the same community will have similar eigenvector values for these dominant eigenvectors. By grouping nodes with similar eigenvector values together, communities can be identified.\n\nThe method starts by calculating the adjacency matrix of the network, which represents the connections between nodes. Next, the eigenvalues and eigenvectors of this matrix are calculated. The eigenvectors with the largest eigenvalues are then used to assign nodes to communities.\n\nThe basic idea is that nodes that belong to the same community will have similar eigenvector values for these dominant eigenvectors. By grouping nodes with similar eigenvector values together, communities can be identified.\n\n## Installation\n\n### Install via PIP\n```cmd\npip install age-cda\n```\n\n### Build from Source\n```cmd\nsudo apt-get update\nsudo apt-get install libeigen3-dev\ngit clone https://github.com/Munmud/Community-Detection-Modularity\ncd Community-Detection-Modularity\npython setup.py install\n```\n- [Configure GSL - GNU Scientific Library](https://solarianprogrammer.com/2020/01/26/getting-started-gsl-gnu-scientific-library-windows-macos-linux/)\n\n### Unit Test\n```cmd\npython -m unittest test_community.py\n```\n\n## Instruction\n\n### import\n```py\nfrom age_cda import Graph\n```\n\n### Create Graph\n```py\nnodes = [0, 1, 2, 3, 4, 5]\nedges = [[0, 1], [0, 2], [1, 2], [2, 3], [3, 4], [3, 5], [4, 5]]\ng = Graph.Graph()\ng.createGraph(nodes, edges)\n```\n- Nodes : `any`\n- Edges : \n - `2d array : adjacency list`\n - `Each element within Nodes array\n\n### Generate Community Assignment\n```py\nres = g.get_community()\n```\n\n### Output Format\n```\n[[3,4,5],[0,1,2]]\n```\n- List community\n- Each community has list of nodes\n\n### Samples\n- [Creating Graph](https://github.com/Munmud/Community-Detection-Modularity/blob/main/Samples/sample1.py)\n- [Zachary's karate club](https://github.com/Munmud/Community-Detection-Modularity/blob/main/Samples/sample2.py)\n\n### Reference\n- [Finding community structure in networks using the eigenvectors of matrices](https://arxiv.org/pdf/physics/0605087.pdf)\n- [Modularity and community structure in networks](https://www.pnas.org/doi/10.1073/pnas.0601602103)\n- [Statistical Mechanics of Community Detection](https://ia903002.us.archive.org/33/items/arxiv-cond-mat0603718/cond-mat0603718.pdf)\n",
"bugtrack_url": null,
"license": "Apache2.0",
"summary": "Detection of Community by maximizing modularity",
"version": "0.0.4",
"split_keywords": [
"community-detection",
"modularity",
"reichardt and bornholdt",
"newman",
"partition network",
"k means cluster"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "0934013014dc9ef2132830e0bb56e04cd8cc66270e51d5ca8ffac856954e25c3",
"md5": "90416f9735e6757b449008e3539ecdd1",
"sha256": "18524addfd66d3a5a6a4c2c81e8a97399afacf08c5d9f862d5fc2867ea6217fe"
},
"downloads": -1,
"filename": "age_cda-0.0.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "90416f9735e6757b449008e3539ecdd1",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 2307881,
"upload_time": "2023-04-16T08:25:48",
"upload_time_iso_8601": "2023-04-16T08:25:48.651223Z",
"url": "https://files.pythonhosted.org/packages/09/34/013014dc9ef2132830e0bb56e04cd8cc66270e51d5ca8ffac856954e25c3/age_cda-0.0.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "dfb664039580f630f5233932d1b7fde297705a983050fc5d8d6a3e2e009fd721",
"md5": "d2fb11196f57b45cb4f35f72160ac2d7",
"sha256": "dcf21a133cec697b6cd9c48cbafe61f7e7552d8efc85e443d6ec73b60e54f4f1"
},
"downloads": -1,
"filename": "age_cda-0.0.4.tar.gz",
"has_sig": false,
"md5_digest": "d2fb11196f57b45cb4f35f72160ac2d7",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 2299289,
"upload_time": "2023-04-16T08:25:50",
"upload_time_iso_8601": "2023-04-16T08:25:50.752984Z",
"url": "https://files.pythonhosted.org/packages/df/b6/64039580f630f5233932d1b7fde297705a983050fc5d8d6a3e2e009fd721/age_cda-0.0.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-04-16 08:25:50",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "Munmud",
"github_project": "Community-Detection-Modularity",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "age-cda"
}