igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] generate random weights for edges under constrain


From: Tamas Nepusz
Subject: Re: [igraph] generate random weights for edges under constrain
Date: Sat, 22 Nov 2014 21:40:10 +0100
User-agent: Mutt/1.5.23 (2014-03-12)

> By "Total number",  I meant sum of edges (edges connected to the same node)
> weight should be less than 1 in the same time each edge should have weight
> from 0 to 1.
There are many possible ways to do it. For instance, let us suppose that you
have N nodes in your graph. In this case, no node will have more than N-1
incident edges (assuming that your graph is simple). In this case, you can
simply draw random numbers from the range [0; 1/N] for each edge, and you can
be absolutely sure that the sum of the weights of the incident edges won't
exceed 1 for any node. Or, you could simply draw random numbers from the [0; 1]
range and assign them as weights to the edges, then find the node with the
largest total weight for its incident edges, and divide *all* the edge weights
with this number. Or, you could divide the weights of the edges incident on the
node only, and the find the next node with the largest total weight as long as
you have at least one node where this weight is larger than 1. But _none_ of
these methods guarantees uniform sampling from the space of all possible edge
combinations, and if you want to be able to sample uniformly (and for all
practical purposes I think you should), then that's a far more complicated
problem.

-- 
T.



reply via email to

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