Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Random walks on weighted networks #52

Open
user1246638 opened this issue Aug 8, 2019 · 1 comment
Open

Random walks on weighted networks #52

user1246638 opened this issue Aug 8, 2019 · 1 comment

Comments

@user1246638
Copy link
Collaborator

Example

import pathpy as pp
import numpy as np

nwk = pp.algorithms.random_graphs.erdoes_renyi_gnm(10,20)
for edge in nwk_w1.edges:
    nwk.edges[edge]["weight"] = np.random.random()
pp.algorithms.random_walk.generate_walk(nwk)

The problem is that the probabilities are not weighted, because weights are not normalized.
The thing is that in an udirected network they cannot be normalized, for example, take graph
A-B-C
because A and C have only one link, weights have to be 1 on both AB and BC edges. But then weights around B are not normalized.

@user1246638
Copy link
Collaborator Author

line 5 in my example code should be
for edge in nwk.edges:

The workaround that I tried is to create a directed network, and then normalize for each node its outgoing edges.
This also fails because of numeric issues: weights sum to 1.00000000000002 or 0.99999999998.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant