Solve for influence of nodes in graph in Matlab

末鹿安然 提交于 2019-12-12 01:10:12

问题


I have a directed, unweighted graph with 5 nodes: x1 through x5. The edges are:

x1->x3
x2->x1
x2->x5
x3->x2
x3->x4
x4->x5
x5->x2

I want to solve this set of equations corresponding to the graph:

x1 = alpha * x2
x2 = alpha * (x3 + x5)
x3 = alpha * x1
x4 = alpha * x3
x5 = alpha * (x2 + x4)
x1 + x2 + x3 + x4 + x5 = 1

How can I set up these equations and solve in Matlab? I want the values of x1 through x5 for which the equations hold.


回答1:


Here is the solution that worked for me:

syms a b c d e alpha
S = solve(-a+alpha*b==0, -b+alpha*c+alpha*d==0, alpha*a-c==0, alpha*c-d==0, ...
alpha*d-e==0, a+b+c+d+e==1);
S = [S.a S.b S.c S.d S.e S.alpha]


来源:https://stackoverflow.com/questions/16255827/solve-for-influence-of-nodes-in-graph-in-matlab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!