[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [igraph] MCL Algorithm
From: |
Gábor Csárdi |
Subject: |
Re: [igraph] MCL Algorithm |
Date: |
Thu, 1 Jan 2009 11:14:12 +0100 |
Thanks Chris, I've added your code to the (experimental and rather
empty) igraph wiki:
http://igraph.wikidot.com/community-detection-in-python
I hope you don't mind.
G.
On Wed, Dec 31, 2008 at 5:11 PM, Chris Wj <address@hidden> wrote:
> Well we certainly appreciate all the work you put in to the library.
>
> Quick Python code snippet I whipped up to test using MLC with igraph (uses
> subprocess and pipes):
>
> import igraph
>
> def igraph_to_mcl_matrix():
> from subprocess import Popen, PIPE
> from cStringIO import StringIO
> G1 = igraph.Graph(n=3)
> G1.add_edges(((0,1),(0,2),(1,2)))
> mcifile = StringIO()
> mclheader = (
> ("\n(mclheader\n"),
> ("mcltype matrix\n"),
> ( "dimensions %sx%s\n)\n" % (G1.vcount(), G1.vcount()) ),
> ("(mclmatrix\n"),
> ("begin\n")
> )
> mcifile.writelines(mclheader)
> for v in G1.vs:
> mcifile.write(str(v.index) + " ")
> for n in G1.neighbors(v.index):
> mcifile.write(str(n) + " ")
> mcifile.write(" $\n")
> mcifile.write(")\n")
> mcifile.seek(0)
> cmd = "mcl - -o -"
> p = Popen(cmd, stdout=PIPE, stdin=PIPE, stderr=PIPE)
> sout,serr = p.communicate(mcifile.read())
> p.wait()
> #print "return code: %i\n" % p.returncode
> if p.returncode==0 and len(sout)>0:
> lines = sout.splitlines()
> idx_begin = lines.index("begin")+1
> idx_end = lines[idx_begin:].index(")")+idx_begin
> for line in lines[idx_begin:idx_end]:
> print line
>
> I used StringIO because I originally was using file IO before piping and it
> was easier to switch the code back and forth between string and file
> objects.
>
> On Wed, Dec 31, 2008 at 3:43 AM, Gábor Csárdi <address@hidden> wrote:
>>
>> Chris,
>>
>> this is always a difficult decision, the main problem is, that it is
>> not easy to do it in a way that allows us to include future updates as
>> well. Furthermore we will need to maintain the code in the future and
>> that is sometimes problematic, a large portion of portability problems
>> we get are due to some 3rd party C++ codes we put into igraph....
>>
>> We already include many smaller and bigger pieces of software, e.g.
>> the walktrap, the spinglass community finding algorithms, parts of
>> ARPACK, LAPACK and BLAS, the BLISS graph isomorphism library, etc.
>>
>> Maybe I am just frustrated because I have been trying to repair the
>> igraph version of ARPACK for a couple of days now....
>>
>> But actually the MCL code looks pretty good. So we will see. Thanks for
>> the tip.
>>
>> Best,
>> Gabor
>>
>> On Tue, Dec 30, 2008 at 11:20 PM, Chris Wj <address@hidden> wrote:
>> > I have been using MCL lately and before working on a way to export
>> > igraph in
>> > MCL matrix format, I was looking to see if there was any further
>> > thoughts on
>> > including this library in igraph. I searched the archives and found that
>> > Tamas said something about possibly including MCL in igraph.
>> > For now, I will probably just exec it (popen) to test it.
>> >
>> > MCL: http://www.micans.org/mcl/
>> >
>> > _______________________________________________
>> > igraph-help mailing list
>> > address@hidden
>> > http://lists.nongnu.org/mailman/listinfo/igraph-help
>> >
>> >
>>
>>
>>
>> --
>> Gabor Csardi <address@hidden> UNIL DGM
>>
>>
>> _______________________________________________
>> igraph-help mailing list
>> address@hidden
>> http://lists.nongnu.org/mailman/listinfo/igraph-help
>
>
> _______________________________________________
> igraph-help mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/igraph-help
>
>
--
Gabor Csardi <address@hidden> UNIL DGM
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [igraph] MCL Algorithm,
Gábor Csárdi <=