A basic tool designed for the construction and visualization of complex, multilayer networks.
Project description
Simple-Network Package
Overview
The Simple-Network Package is a powerful tool designed for the construction and visualization of complex, multilayer networks. With an emphasis on ease of use and flexibility, this package allows users to create intricate network structures and render them in stunning 3D using Python. Whether for academic research, data analysis, or educational purposes, this package offers the functionality needed to bring your network visualizations to life.
Features
- Multilayer Network Creation: Easily define multiple layers within your networks, adding nodes and edges with customizable attributes.
- 3D Interactive Visualization: Utilize the integrated visualization tools to explore your networks in a dynamic 3D space.
- Customizable Attributes: Set and manage attributes for nodes and edges to represent complex relationships and properties.
- Python 3.x Support: Compatible with modern Python environments, ensuring seamless integration into your projects.
Prerequisites
The package is compatible with Python 3.x environments and requires the following libraries:
NumPy
Plotly
Installing Dependencies
First, install the required libraries using the following command:
pip install numpy plotly
Installation
To install the Simple-Network Package, ensure you have Python 3.x installed on your system. The package depends on NumPy and Plotly, which will be installed automatically if you don't have them already.
pip install Simple-Network
This package offers comprehensive tools for constructing and visualizing complex multilayer networks in a 3D space. It features two primary components: MultilayerNetwork, for creating the network structure, and Visualize, for rendering the network interactively in 3D.
Usage
Building a Multilayer Network
To start building a multilayer network, import the MultilayerNetwork class from the package:
from simpleG import MultilayerNetwork
Initialize the network
graph = MultilayerNetwork()
Adding Layers
graph.add_layer(layer_name='Layer_1')
Adding Nodes
graph.add_node(layer_name='Layer_1', node=1)
graph.add_node(layer_name='Layer_1', node=4)
Adding Edges
graph.add_edge(node1=1, node2=4, layer_name='Layer_1', weight=1)
Setting Node and Edge Attributes
graph.set_node_attribute(node=1, attr_name='attr1', attr_value='value1')
graph.set_edge_attribute(node1=1, node2=4, layer_name='Layer_1', attr_name='attr1', attr_value='value1')
Visualizing the Network
To visualize the network in 3D:
from visualize import Visualize
# Create an instance of Visualize with the network
visualizer = Visualize(network=graph)
# Visualize the network
visualizer.show_graph(edge_visibility_threshold=0.1)
Alternatively:
Visualize(graph).show_graph()
Examples
For basic usage examples, please refer to the Jupyter Notebook in the Examples folder.
API Reference
Class: MultilayerNetwork
Attributes:
directed (bool): Indicates whether the network edges are directed.
node_count (int): Total number of unique nodes in the network.
node (list): List of unique nodes.
nodes (dict): Nodes organized by layer. Format: {layer_name: [nodes]}
edges (dict): Edge weights organized by layer. Format: {layer_name: numpy_array}
layers (list): List of layer names.
node_attributes (dict): Node attributes. Format: {node: {attr_name: attr_value}}
edge_attributes (dict): Edge attributes. Format: {(layer_name, node1, node2): {attr_name: attr_value}}
inter_layer_edges (list): Edges between layers. Format: (node1, layer1, node2, layer2, weight)
Methods:
__init__(self, directed=False): Initializes a new network. Defaults to undirected.
add_layer(self, layer_name): Adds a new layer. If it exists, does nothing.
add_node(self, layer_name, node): Adds a node to a layer. Creates layer if non-existent.
add_edge(self, node1, node2, layer_name, weight=1): Adds an edge within a layer. Initializes layer if needed.
set_node_attribute(self, node, attr_name, attr_value): Sets an attribute for a node.
set_edge_attribute(self, node1, node2, layer_name, attr_name, attr_value): Sets an attribute for an edge.
add_inter_layer_edge(self, node1, layer1, node2, layer2, weight=1): Adds an edge between two different layers.
Additional methods detailed in the documentation handle internal operations, node and edge validation, and network analysis functions such as calculating node degrees within layers.
Class: Visualize
The Visualize class enables interactive 3D visualization of networks using Plotly.
Methods:
show_graph(edge_visibility_threshold=0.1): Renders the network in 3D. Edges below the specified visibility threshold are not displayed.
Contributing
We welcome contributions to the MultilayerNetwork Package. Please refer to GitHub contributing guidelines for more information on how to participate in the development.
License
This project is licensed under the MIT License. For more details, see the LICENSE file in the project repository.
Contact
email: cloner174.org@gmail.com
other: https://t.me/PythonLearn0
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file Simple-Network-0.1.0.tar.gz.
File metadata
- Download URL: Simple-Network-0.1.0.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
236d304a80f6d0c1478c06f7c857e03298ef33e947e681dfead1cd1f2d04efe0
|
|
| MD5 |
0e69a619abcab30234a4b3aa46740d3a
|
|
| BLAKE2b-256 |
09b519979b0c26faccd395c0d25ed3d0ea3ba9ec013e1ca0c40738b86550d588
|
File details
Details for the file Simple_Network-0.1.0-py3-none-any.whl.
File metadata
- Download URL: Simple_Network-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
243a6c9afbd714c175c475de0d00b3e971eb971ba2a007f07de877422052825b
|
|
| MD5 |
0aa000729732ea973038b3317afddf92
|
|
| BLAKE2b-256 |
25392a549a21c58863e3efded46cb23d40ea957b1b4dd85ea6006ff984534657
|