[Top][All Lists]

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

Re: [igraph] edge betweenness

From: Tamas Nepusz
Subject: Re: [igraph] edge betweenness
Date: Mon, 17 Nov 2008 17:48:44 +0000

in the python interface is there a way to terminate the algorithm before completion?
Well, you can kill it by Ctrl-C, but you lose the results of course ;) There's no other way to stop it. However, you can implement the whole algorithm using Graph.edge_betweenness and a simple loop:

orig_ecount = g.ecount()
while g.ecount() > 0:
  # record g.clusters() somewhere or do what you want with it
  # calculate the edge betweenesses
  ebs = g.edge_betweenness()
  # find the index of the edge with the maximum betweenness
  max_idx = max(xrange(len(ebs)), key = ebs.__getitem__)
  # remove that edge
  # show progress report
  print "%.2f%% of edges removed" % (g.ecount() / orig_ecount * 100.)

or something like that. This is untested, but it should work.


reply via email to

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