netds


Namenetds JSON
Version 0.1 PyPI version JSON
download
home_pageNone
SummaryNone
upload_time2024-10-21 02:10:38
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Network Community Detection and Visualization

This repository provides a set of functions to perform community detection on networks using algorithms like Girvan-Newman and Louvain. Additionally, it includes utilities to calculate modularity and visualize the detected communities with various layouts.

## Functions Overview

### 1. `calculate_modularity(G, partition)`
This function calculates the modularity of a given partition of a graph `G`. Modularity is a measure of the strength of division of a network into communities.

- **Parameters**:
  - `G` (networkx.Graph): The input graph.
  - `partition` (list of sets or dict): The partition of the graph where each set (or dict) represents a community.
  
- **Returns**:
  - `float`: The modularity score.

### 2. `get_modularity(G, partition)`
This function calculates the modularity of the current partition using an alternative method based on node degrees and community assignments.

- **Parameters**:
  - `G` (networkx.Graph): The graph for which modularity is to be calculated.
  - `partition` (dict): A dictionary where keys are nodes and values are community labels.
  
- **Returns**:
  - `float`: The modularity score.

### 3. `local_optimization_step(H, Q_max)`
This function performs a local optimization step on the graph to maximize modularity by moving nodes to neighboring communities.

- **Parameters**:
  - `H` (networkx.Graph): The graph with community assignments as node attributes.
  - `Q_max` (float): The current maximum modularity.
  
- **Returns**:
  - `float`: The updated maximum modularity after the optimization step.

### 4. `network_aggregation_step(H)`
This function performs the network aggregation step by collapsing communities into super-nodes and recalculating edge weights between communities.

- **Parameters**:
  - `H` (networkx.Graph): The graph where each node has a 'community' attribute.
  
- **Returns**:
  - `networkx.Graph`: A new graph where nodes represent communities from the previous step.

### 5. `reindex_communities(partition)`
This function reindexes the communities in the partition so that community labels are continuous.

- **Parameters**:
  - `partition` (dict): A dictionary where keys are nodes and values are community labels.
  
- **Returns**:
  - `dict`: A new partition where community labels are reindexed.

### 6. `louvain_method(G, init=None)`
This function runs the Louvain method for community detection on a graph.

- **Parameters**:
  - `G` (networkx.Graph): The input graph where nodes and edges define the structure.
  - `init` (dict): Optional initial partition.
  
- **Returns**:
  - `dict`: The final partition of the graph with node assignments to communities.

### 7. `vis_network_spring(G, best_partition, layout_type="spring_layout")`
This function visualizes a network with a specified layout, coloring nodes by community.

- **Parameters**:
  - `G` (networkx.Graph): The graph to visualize.
  - `best_partition` (dict): A partition of the graph nodes (community assignments).
  - `layout_type` (str): The layout algorithm to use. Options are "spring_layout", "shell_layout", and "kamada_kawai_layout".
  
- **Returns**:
  - `None`: Displays the network graph.

### 8. `vis_network_agg_spring(G, best_partition, layout1="shell_layout", iterations=1)`
This function visualizes a network using an aggregated layout approach. The first layout is either 'shell_layout' or 'kamada_kawai_layout', and the second layout is always 'spring_layout' for a specified number of iterations.

- **Parameters**:
  - `G` (networkx.Graph): The graph to visualize.
  - `best_partition` (dict): A partition of the graph nodes (community assignments).
  - `layout1` (str): The first layout algorithm to use, either 'shell_layout' or 'kamada_kawai_layout'.
  - `iterations` (int): The number of iterations for the 'spring_layout' adjustment.
  
- **Returns**:
  - `None`: Displays the network graph.

### 9. `vis_network_partition_process(G, pos=None, method="girvan_newman", w=5.0, h=4.0, nrows=6, ncols=6, iterations_limit=None)`
This function visualizes the partitioning process of a network using the Girvan-Newman algorithm.

- **Parameters**:
  - `G` (networkx.Graph): The input graph.
  - `pos` (dict or None): Positions for the nodes in the graph. If None, default spring_layout will be used.
  - `method` (str): Only "girvan_newman" is supported.
  - `w` (float): Width of each subplot.
  - `h` (float): Height of each subplot.
  - `nrows` (int): Number of rows in the grid of subplots.
  - `ncols` (int): Number of columns in the grid of subplots.
  - `iterations_limit` (int): Limit the number of iterations to display.
  
- **Returns**:
  - `None`: Displays the partitioning process.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "netds",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": null,
    "author": null,
    "author_email": "liu-yi-xuan <53630521+liu-yi-xuan@users.noreply.github.com>",
    "download_url": "https://files.pythonhosted.org/packages/fb/fb/1ad14e68c352148d57c3f1fcbb6b850f62bd9f0b775a82754d23bb67ccc8/netds-0.1.tar.gz",
    "platform": null,
    "description": "# Network Community Detection and Visualization\n\nThis repository provides a set of functions to perform community detection on networks using algorithms like Girvan-Newman and Louvain. Additionally, it includes utilities to calculate modularity and visualize the detected communities with various layouts.\n\n## Functions Overview\n\n### 1. `calculate_modularity(G, partition)`\nThis function calculates the modularity of a given partition of a graph `G`. Modularity is a measure of the strength of division of a network into communities.\n\n- **Parameters**:\n  - `G` (networkx.Graph): The input graph.\n  - `partition` (list of sets or dict): The partition of the graph where each set (or dict) represents a community.\n  \n- **Returns**:\n  - `float`: The modularity score.\n\n### 2. `get_modularity(G, partition)`\nThis function calculates the modularity of the current partition using an alternative method based on node degrees and community assignments.\n\n- **Parameters**:\n  - `G` (networkx.Graph): The graph for which modularity is to be calculated.\n  - `partition` (dict): A dictionary where keys are nodes and values are community labels.\n  \n- **Returns**:\n  - `float`: The modularity score.\n\n### 3. `local_optimization_step(H, Q_max)`\nThis function performs a local optimization step on the graph to maximize modularity by moving nodes to neighboring communities.\n\n- **Parameters**:\n  - `H` (networkx.Graph): The graph with community assignments as node attributes.\n  - `Q_max` (float): The current maximum modularity.\n  \n- **Returns**:\n  - `float`: The updated maximum modularity after the optimization step.\n\n### 4. `network_aggregation_step(H)`\nThis function performs the network aggregation step by collapsing communities into super-nodes and recalculating edge weights between communities.\n\n- **Parameters**:\n  - `H` (networkx.Graph): The graph where each node has a 'community' attribute.\n  \n- **Returns**:\n  - `networkx.Graph`: A new graph where nodes represent communities from the previous step.\n\n### 5. `reindex_communities(partition)`\nThis function reindexes the communities in the partition so that community labels are continuous.\n\n- **Parameters**:\n  - `partition` (dict): A dictionary where keys are nodes and values are community labels.\n  \n- **Returns**:\n  - `dict`: A new partition where community labels are reindexed.\n\n### 6. `louvain_method(G, init=None)`\nThis function runs the Louvain method for community detection on a graph.\n\n- **Parameters**:\n  - `G` (networkx.Graph): The input graph where nodes and edges define the structure.\n  - `init` (dict): Optional initial partition.\n  \n- **Returns**:\n  - `dict`: The final partition of the graph with node assignments to communities.\n\n### 7. `vis_network_spring(G, best_partition, layout_type=\"spring_layout\")`\nThis function visualizes a network with a specified layout, coloring nodes by community.\n\n- **Parameters**:\n  - `G` (networkx.Graph): The graph to visualize.\n  - `best_partition` (dict): A partition of the graph nodes (community assignments).\n  - `layout_type` (str): The layout algorithm to use. Options are \"spring_layout\", \"shell_layout\", and \"kamada_kawai_layout\".\n  \n- **Returns**:\n  - `None`: Displays the network graph.\n\n### 8. `vis_network_agg_spring(G, best_partition, layout1=\"shell_layout\", iterations=1)`\nThis function visualizes a network using an aggregated layout approach. The first layout is either 'shell_layout' or 'kamada_kawai_layout', and the second layout is always 'spring_layout' for a specified number of iterations.\n\n- **Parameters**:\n  - `G` (networkx.Graph): The graph to visualize.\n  - `best_partition` (dict): A partition of the graph nodes (community assignments).\n  - `layout1` (str): The first layout algorithm to use, either 'shell_layout' or 'kamada_kawai_layout'.\n  - `iterations` (int): The number of iterations for the 'spring_layout' adjustment.\n  \n- **Returns**:\n  - `None`: Displays the network graph.\n\n### 9. `vis_network_partition_process(G, pos=None, method=\"girvan_newman\", w=5.0, h=4.0, nrows=6, ncols=6, iterations_limit=None)`\nThis function visualizes the partitioning process of a network using the Girvan-Newman algorithm.\n\n- **Parameters**:\n  - `G` (networkx.Graph): The input graph.\n  - `pos` (dict or None): Positions for the nodes in the graph. If None, default spring_layout will be used.\n  - `method` (str): Only \"girvan_newman\" is supported.\n  - `w` (float): Width of each subplot.\n  - `h` (float): Height of each subplot.\n  - `nrows` (int): Number of rows in the grid of subplots.\n  - `ncols` (int): Number of columns in the grid of subplots.\n  - `iterations_limit` (int): Limit the number of iterations to display.\n  \n- **Returns**:\n  - `None`: Displays the partitioning process.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": null,
    "version": "0.1",
    "project_urls": {
        "Documentation": "https://github.com/liu-yi-xuan/netdata#readme",
        "Issues": "https://github.com/liu-yi-xuan/netdata/issues",
        "Source": "https://github.com/liu-yi-xuan/netdata"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "4c7ec86f5c086210676728ea1c94c083717071097179c22239bec570c3de74b0",
                "md5": "ab639bab97b9f698e9714269f1eccc27",
                "sha256": "1489e9c7e8227a6fa19d7a6dfd145220d520965277e900586d160524c1358f48"
            },
            "downloads": -1,
            "filename": "netds-0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ab639bab97b9f698e9714269f1eccc27",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 15540,
            "upload_time": "2024-10-21T02:10:36",
            "upload_time_iso_8601": "2024-10-21T02:10:36.316660Z",
            "url": "https://files.pythonhosted.org/packages/4c/7e/c86f5c086210676728ea1c94c083717071097179c22239bec570c3de74b0/netds-0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "fbfb1ad14e68c352148d57c3f1fcbb6b850f62bd9f0b775a82754d23bb67ccc8",
                "md5": "a61bad27e188706a4544ea1a8ef6da98",
                "sha256": "4b2f2a9d6663d4721f523c019ee725454f614a3b9e626f0bcbf3c4b9e82b10c1"
            },
            "downloads": -1,
            "filename": "netds-0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "a61bad27e188706a4544ea1a8ef6da98",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 8743,
            "upload_time": "2024-10-21T02:10:38",
            "upload_time_iso_8601": "2024-10-21T02:10:38.058514Z",
            "url": "https://files.pythonhosted.org/packages/fb/fb/1ad14e68c352148d57c3f1fcbb6b850f62bd9f0b775a82754d23bb67ccc8/netds-0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-21 02:10:38",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "liu-yi-xuan",
    "github_project": "netdata#readme",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "netds"
}
        
Elapsed time: 0.47715s