Giter Site home page Giter Site logo

python-louvain's Introduction

Louvain Community Detection

Installing

To build and install run from source:

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. You will find documentation about this module at http://python-louvain.readthedocs.io/

Usage

To use as a python library:

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

# Replace this with your networkx graph loading depending on your format !
G = nx.erdos_renyi_graph(30, 0.05)

#first compute the best partition
partition = community.best_partition(G)

#drawing
size = float(len(set(partition.values())))
pos = nx.spring_layout(G)
count = 0.
for com in set(partition.values()) :
    count = count + 1.
    list_nodes = [nodes for nodes in partition.keys()
                                if partition[nodes] == com]
    nx.draw_networkx_nodes(G, pos, list_nodes, node_size = 20,
                                node_color = str(count / size))


nx.draw_networkx_edges(G, pos, alpha=0.5)
plt.show()

There is also a command line:

$ community <filename>

filename is a binary file as generated by the convert utility distributed with the C implementation at https://sites.google.com/site/findcommunities/ This is mostly for debugging purpose and I advise to use this module more as a library with your graph loading code than with this command.

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:

pip install nose
python setup.py test

image

Documentation Status

python-louvain's People

Contributors

taynaud avatar toddrme2178 avatar pavlin-policar avatar bricaud avatar thedomdom avatar lukecyca avatar mahdi5534 avatar mriduls avatar altsoph avatar

Stargazers

Christina Taft avatar

Forkers

worldie-com

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.