Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
Clarified the python version requirement and the dependencies
  • Loading branch information
saref authored Jan 2, 2024
1 parent d3100da commit dcdb27f
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
bayanpy is a Python package implementing the Bayan algorithm, a community detection method capable of providing a globally optimal solution to the modularity maximization problem. Bayan can also be implemented such that it provides an approximation of the maximum modularity with a guarantee of proximity. This algorithm is theoretically grounded by the Integer Programming (IP) formulation of the modularity maximization problem and relies on an exact branch-and-cut scheme for solving the NP-complete optimization problem to global optimality.

For more information, visit the [Bayan project website](https://bayanproject.github.io/).
For a few examples of different ways you can use Bayan see this Google Colab address: [bayanpy Examples](https://tinyurl.com/bayancolab).
For a few examples on different ways you can use Bayan see this Google Colab notebook: [bayanpy Examples](https://tinyurl.com/bayancolab).


## Installation
Expand All @@ -26,22 +26,23 @@ bayanpy has the following dependencies:
- joblib>=1.1.0
- pycombo>=0.1.7

These packages will be automatically installed when you install bayanpy using pip.
Note that pycombo requires Python version =<3.9 and therefore bayanpy has the same python version requirement.

The dependencies above will be automatically installed when you install bayanpy using pip.



### Gurobi Installation with Free Academic License

bayanpy requires Gurobi Optimizer for models with more than 2000 variables or 2000 constraints. Gurobi is a commercial software, but it can be registered with a free academic license if the user is affiliated with a recognized degree-granting academic institution.
bayanpy requires Gurobi Optimizer. Gurobi is a commercial software, but it can be registered with a free academic license if the user is affiliated with an academic institution. Due to the restrictions of Gurobi, Bayan requires a (free academic) Gurobi license for processing any graph with more than sqrt(2000) ≈ 44 nodes.

Follow these steps to install Gurobi with a free academic license:

1. Download and install Python 3.9 (or a later version) from [the official Python website](https://www.python.org/downloads/).
1. Download and install Python version 3.9 from [the official Python website](https://www.python.org/downloads/).
2. Register for an account on [the Gurobi registration page](https://pages.gurobi.com/registration) to get a free academic license for using Gurobi.
3. Download and install Gurobi Optimizer (version 10.0 or later) from [the Gurobi downloads page](https://www.gurobi.com/downloads/gurobi-optimizer-eula/) after reading and agreeing to Gurobi's End User License Agreement.
4. Install Gurobi into Python by running the following commands in a terminal:
3. Download and install Gurobi Optimizer (version >= 9.5, latest version is recommended) from [the Gurobi downloads page](https://www.gurobi.com/downloads/gurobi-optimizer-eula/) after reading and agreeing to Gurobi's End User License Agreement.
4. Install Gurobi into Python by running the following commands (either using conda or pip) in a terminal:
- Using Conda (recommended for Anaconda users):

```
conda config --add channels http://conda.anaconda.org/gurobi
conda install gurobi
Expand All @@ -52,10 +53,9 @@ conda install gurobi
pip install gurobipy
```


5. Request an academic license from [the Gurobi academic license page](https://www.gurobi.com/downloads/end-user-license-agreement-academic/) and install the license on your computer following the instructions given on the Gurobi license page.

For detailed installation instructions, refer to the Gurobi Quick Start Guides for [Windows](https://www.gurobi.com/documentation/10.0/quickstart_windows/index.html), [Linux](https://www.gurobi.com/documentation/10.0/quickstart_linux/index.html), or [macOS](https://www.gurobi.com/documentation/10.0/quickstart_mac/index.html).
For detailed installation instructions, refer to the Gurobi's [Quick Start Guides](https://support.gurobi.com/hc/en-us/articles/14799677517585-Getting-Started-with-Gurobi-Optimizer).

## Usage

Expand All @@ -65,7 +65,7 @@ You can use bayanpy as a standalone package. After installing bayanpy, you can u
import networkx as nx
import bayanpy

# Create or load your networkx graph (undirected)
# Create or load your networkx (undirected) graph
graph = nx.florentine_families_graph()

# Run the Bayan algorithm
Expand All @@ -76,22 +76,22 @@ modularity, optimality_gap, community, modeling_time, solve_time = bayanpy.bayan

#### Parameters and acceptable input

- `graph`: Input graph should be an undirected networkx graph. You can use the edge attribute "weight" to represent positive edge weights.
- `graph`: Input graph should be an undirected networkx graph. If the graph is weighted, it must have edge attribute "weight" to store positive edge weights.
- `threshold`: The acceptable optimality gap for the algorithm to terminate. If Bayan finds a solution with a modularity value within the specified threshold of the optimal solution, it stops the search and returns the found solution. For example, setting the threshold to 0.01 means Bayan will stop when it finds a solution within 1% of the maximum modularity for that graph.
- `time_allowed`: The maximum allowed execution time in seconds for Bayan to search for a solution. Shortly after this time limit is reached, the algorithm will terminate and returns the best solution found so far, even if the optimality gap threshold has not been met.
- `time_allowed`: The maximum allowed execution time in seconds for Bayan to search for a solution after the optimization model is built (formulated). Shortly after this time limit is reached, the algorithm will terminate and returns the best solution found so far, even if the optimality gap threshold is not met.
- `resolution`: The resolution parameter (gamma) used in the modularity function.

#### Returns

- `modularity`: The modularity value of the returned partition.
- `optimality_gap`: The guaranteed upper bound of the percentage difference between the modularity of the returned partition and the maximum modularity.
- `community`: A nested list describing the community assignment of the returned partition.
- `optimality_gap`: The upper bound for the percentage difference between the modularity of the returned partition and the maximum modularity.
- `community`: A nested list describing the communities (the partition).
- `modeling_time`: The seconds taken for pre-processing the input and formulating the optimization model.
- `solve_time`: The seconds taken for solving the optimization model using the Bayan algorithm.


### Example
You can find a few examples of different ways Bayan can be used at this Google Colab address: [bayanpy Examples](https://tinyurl.com/bayancolab)
You can find a few examples on Bayan in this Google Colab notebook: [bayanpy Examples](https://tinyurl.com/bayancolab)


## Contributing
Expand All @@ -105,4 +105,3 @@ bayanpy is released under the [GNU General Public License](LICENSE). For more in




0 comments on commit dcdb27f

Please sign in to comment.