igraph-help
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [igraph] Assign Weight to Link by Counting Repetitions


From: Tamas Nepusz
Subject: Re: [igraph] Assign Weight to Link by Counting Repetitions
Date: Fri, 2 Oct 2009 11:19:23 +0100
User-agent: Mutt/1.5.17 (2007-11-01)

> I have a nice and clean graph without self-loops and repeated edges. It is 
> OK for me to get rid of self-loops, but my only problem is that I would 
> like to keep the info about how many times each edge used to appear and I 
> would like to store this info as a weight associated to the edge itself.
> Any suggestions about how to achieve that efficiently?
I'd start with some command line magic:

$ cat my_graph.txt
1 2
1 2
1 2
2 3
2 3
3 1

$ cat my_graph.txt | sort | uniq -c | awk '{ print $2, $3, $1 }' >my_graph.ncol

After that, you can load the generated NCOL file into igraph. The counts
will be assigned as weights, but you'll still have to get rid of
self-loops using simplify() -- or you can do that in the awk call above
by checking whether $2 and $3 are equal or not.

-- 
Tamas




reply via email to

[Prev in Thread] Current Thread [Next in Thread]