老师参与

作网络图的代码为什么要用结构矩阵

澄碧钓徒 发表于2018年05月17日
<p><img src="https://nos.netease.com/edu-image/069ebe08-b626-44d1-9c0f-5750142cb378.JPG" /></p><p>这段代码中的h.Nodes(path)是结构矩阵吧,又感觉不太像,好像结构矩阵&quot;.&quot;两边是反过来的?还有图论这部分的代码明显有点难理解,希望最好能加上注释改善下可读性……</p><p>另外,最近MATLAB解释器不知为何抽风,有的程序明明没有问题却会莫名其妙报错(主要是f开头的函数),找到相应的库函数文件打开再调试竟然就恢复正常了,太匪夷所思</p>
1 回复

    1楼

  • 龚劬 发表于2018年05月19日
    1 | 0 | 举报
    <p>h是biograph对象的句柄,可用get(h)返回句柄值h所指定对象的所有属性名称与相对应的属性值,h.Nodes是结构矩阵,如:</p><p>&gt;&gt; G=sparse( [ 2,3,1,3,3,5,4, 4,1,7,6,6,5, 5,11, 1,8,6,9,10,8,9, 9,10],...</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [3,4,2,7,5,3,5,11,7,6,7,5,6,11, 5, 8,1,9,5,11,9,8,10,9],...</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [3,5,8,5,6,6,1,12,7,9,9,2,2,10,10,8,8,3,7, 2, 9,9, 2, 2]);</p><p>&gt;&gt; h = view(biograph(G,[],'ShowWeights','on'))</p><p>&gt;&gt; s=get(h)</p><p><br ></p><p>s =&nbsp;</p><p>&nbsp; 包含以下字段的 struct:</p><p><br ></p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ID: ''</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Label: ''</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Description: ''</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;LayoutType: 'hierarchical'</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; LayoutScale: 1</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Scale: 1</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;NodeAutoSize: 'on'</p><p>&nbsp; &nbsp; &nbsp; ShowTextInNodes: 'id'</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;EdgeType: 'curved'</p><p>&nbsp; &nbsp; &nbsp; &nbsp; EdgeTextColor: [0 0 0]</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ShowArrows: 'on'</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ArrowSize: 8</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ShowWeights: 'on'</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;EdgeFontSize: 8</p><p>&nbsp; &nbsp; &nbsp; &nbsp; NodeCallbacks: @(node)inspect(node)</p><p>&nbsp; &nbsp; &nbsp; &nbsp; EdgeCallbacks: @(edge)inspect(edge)</p><p>&nbsp; &nbsp; CustomNodeDrawFcn: []</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Nodes: [11×1 biograph.node]</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Edges: [24×1 biograph.edge]</p><p><br ></p><p><br ></p><p><br ></p><p><br ></p>
    龚劬 发表于2018年05月19日
    添加评论