Skip to content

Commit

Permalink
fix README
Browse files Browse the repository at this point in the history
added TODO list
  • Loading branch information
koteth committed Sep 16, 2014
1 parent ae1ed86 commit 6ac7326
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 27 deletions.
26 changes: 12 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@
This module implements the Markov Cluster algorithm created by Stijn van Dongen and
described in http://www.library.uu.nl/digiarchief/dip/diss/1895620/inhoud.htm.

This implementation si not yet optimized for large networks.
This implementation is not yet optimized for large networks.

![example] (example.png)


## Installation:
## Installation

python setup.py install

##Usage:
##Usage

###Command line:
###Command line

Usage: mcl_clustering.py [options] <input_matrix>

Options:
Options
-h, --help show this help message and exit
-e EXPAND_FACTOR, --expand_factor=EXPAND_FACTOR
expand factor (default: 2)
Expand All @@ -41,7 +41,7 @@ An example is the file example.csv.
try mcl_clustering.py -e 3 example.csv


###Code:
###Code

####Using numpy adjacency matrix

Expand All @@ -66,32 +66,30 @@ try mcl_clustering.py -e 3 example.csv
mult_factor = <mult_factor>)


Output:
Output
M = otuput matrix
clusters = dict with keys = [<cluster id>] values = [<vertex id>]

##Requirements:
##Requirements

numpy
networkx


##Parameters:
##Parameters

-i --inflate-factor
-e --expand-factor
-m --multiply-factor
-l --max-loops
-s --show-graph show graph with networkx

## References

## References:

[1] Stijn van Dongen, Graph Clustering by Flow Simulation.
* [1] Stijn van Dongen, Graph Clustering by Flow Simulation.
PhD thesis, University of Utrecht, May 2000.
( http://www.library.uu.nl/digiarchief/dip/diss/1895620/inhoud.htm )

[2] Stijn van Dongen. A cluster algorithm for graphs. Technical Report
* [2] Stijn van Dongen. A cluster algorithm for graphs. Technical Report
INS-R0010, National Research Institute for Mathematics and Computer
Science in the Netherlands, Amsterdam, May 2000.
( http://www.cwi.nl/ftp/CWIreports/INS/INS-R0010.ps.Z )
Expand Down
4 changes: 4 additions & 0 deletions TODO
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- improve graph visualization
- improve unittest
- use numpy sparse matrices instead of numpy arrays
- speedup the algo
23 changes: 12 additions & 11 deletions mcl/mcl_clustering.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def draw(G, A, cluster_map):

colors = []
for i in range(len(G.nodes())):
colors.append( clust_map.get(i, 100 ))
colors.append(clust_map.get(i, 100))

pos = nx.spring_layout(G)
nx.draw_networkx_nodes(G, pos,node_size = 200, node_color =colors , cmap=plt.cm.Blues )
Expand All @@ -70,7 +70,6 @@ def mcl(M, expand_factor = 2, inflate_factor = 2, max_loop = 10 , mult_factor =
M = add_diag(M, mult_factor)
M = normalize(M)


for i in range(max_loop):
logging.info("loop", i)
M = inflate(M, inflate_factor)
Expand Down Expand Up @@ -149,6 +148,16 @@ def get_graph(csv_filename):
G = nx.from_numpy_matrix(np.matrix(M))
return np.array(M), G

def clusters_to_output(clusters, options):
if options.output and len(options.output)>0:
f = open(options.output, 'w')
for k, v in clusters.items():
f.write("%s|%s\n" % (k, ", ".join(map(str, v)) ))
f.close()
else:
print "Clusters:"
for k, v in clusters.items():
print k, v

if __name__ == '__main__':

Expand All @@ -165,15 +174,7 @@ def get_graph(csv_filename):
mult_factor = options.mult_factor)
print time.time(), "done\n"

if options.output and len(options.output)>0:
f = open(options.output, 'w')
for k, v in clusters.items():
f.write("%s|%s\n" % (k, ", ".join(map(str, v)) ))
f.close()
else:
print "Clusters:"
for k, v in clusters.items():
print k, v
clusters_to_output(clusters, options)

if options.draw:
print time.time(), "drawing..."
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from distutils.core import setup

setup(
name='MCL Markov Clustering',
name='MCL Markov Cluster',
version='0.3',
description='Markov Clustering algoritm for Graphs',
description='Markov Cluster algorithm implementation',
scripts = [
'mcl/mcl_clustering.py'
],
Expand Down

0 comments on commit 6ac7326

Please sign in to comment.