xyjprc / hon

Code for generating Higher-order Network (HON) from data with higher-order dependencies
http://advances.sciencemag.org/content/2/5/e1600028
MIT License
64 stars 19 forks source link

Rewiring question #3

Open xindi-dumbledore opened 6 years ago

xindi-dumbledore commented 6 years ago

Hi~ Sorry I have many questions on this algorithm haha. I'm trying to fully understand the algorithm and I have a question on the REWIRE(r) function.

Suppose we already have already encounter a->b, w1 in our G, now we encounter a rule, r = b|a->c w2, and we want to rewire it. Based on the algorithm PrevSource = a, PrevTarget = b, and indeed edge(a, b|a) not in the graph, then we add the edge (a, b|a, w2) and remove (a, b). Is this correct?

So I'm confused why we make the edge (a, b|a) has weight w2, w2 can be different from w1 right? So we may overcount or undercount the transition between a and b? It seems weird that the transition between a and b is related to c. And one can also imagine, if we have b|a -> d, w3, then the weight of (a, b|a) will change if we encounter b|a -> d first and b|a->c second (since we don't need to rewire under this circumstances).

Thank you so much!

xyjprc commented 6 years ago

Hi @xindi-dumbledore , thank you for your question. This does seem to be a bug in this pyHON code.

If we have a->b, w1 and b|a->c w2, then the first link a->b w1 should be rewired as a->b|a w1.

For b|a->c w2, source = b|a, PrevSource = a and PrevTarget = b. We should assign PrevSource -> source = w1, which is G[PrevSource][PrevTarget]. My current code incorrectly assigns Graph[source][target] (w2) to a->b|a.

That's a good catch! Thank you again, and please kindly let me know if you notice any other issue.

xyjprc commented 6 years ago

Also just checked the same step in the Lisp version of the code (cl-HON) which looked correct. Just pyHON's bug.