Git Product home page Git Product logo

python-louvain's Introduction

Louvain Community Detection

image

Documentation Status

Installing

To build and install from source, run

python setup.py install

You can also install from pip with

pip install python-louvain

The package name on pip is python-louvain but it is imported as community in python. More documentation for this module can be found at http://python-louvain.readthedocs.io/

Usage

To use as a Python library

import community as community_louvain
import matplotlib.cm as cm
import matplotlib.pyplot as plt
import networkx as nx

# load the karate club graph
G = nx.karate_club_graph()

# compute the best partition
partition = community_louvain.best_partition(G)

# draw the graph
pos = nx.spring_layout(G)
# color the nodes according to their partition
cmap = cm.get_cmap('viridis', max(partition.values()) + 1)
nx.draw_networkx_nodes(G, pos, partition.keys(), node_size=40, 
                       cmap=cmap, node_color=list(partition.values()))
nx.draw_networkx_edges(G, pos, alpha=0.5)
plt.show()

It can also be run on the command line

$ community <filename>

where filename is a binary file as generated by the convert utility distributed with the C implementation at https://sites.google.com/site/findcommunities/ However as this is mostly for debugging purposes its use should be avoided. Instead importing this library for use in Python is recommended.

Documentation

You can find documentation at https://python-louvain.readthedocs.io/

To generate documentation, run

pip install numpydoc sphinx
cd docs
make

Tests

To run tests, run

pip install nose
python setup.py test

python-louvain's People

Contributors

akenney avatar altsoph avatar asellappen avatar bricaud avatar dalwar23 avatar lukecyca avatar mahdi5534 avatar mriduls avatar nikoleta-v3 avatar pavlin-policar avatar pbourke avatar richardmillson avatar taynaud avatar thedomdom avatar toddrme2178 avatar villanuevab avatar zhouhanc avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.