【问题标题】:Organizing data to use Graphshortestpath Function - Matlab组织数据以使用 Graphshortestpath 函数 - Matlab
【发布时间】:2012-05-02 04:15:03
【问题描述】:

我知道 Matlab 中 Graphshortestpath Function 背后的概念,但是我必须重新编码这部分以再次连接路径。

W = [44.35 45.84 41.19 23.81 59.86 68.63 29.99 24.13 47.3 30.36 500];
DG = sparse([1 2 3 4 5 6 7 8 9 10 11],[2 3 4 5 6 7 8 9 10 11 1],W);
UG = tril(DG + DG');

还有其他方法可以让我的生活更轻松吗?我有大量数据需要输入系统,我的数据是 Excel 格式。我不可能每次都重新编码。非常感谢您的帮助!谢谢:)

【问题讨论】:

    标签: excel matlab shortest-path


    【解决方案1】:

    如果您仍在寻找解决方法,我有一个建议。

    如果您在 Excel 中有数据,您可以将 Edge 列表导入到变量中,例如

    E=importdata('edgelist.txt')

    然后将权重导入另一个变量中

    W=importdata("weights.txt')

    剩下的就是使用如下命令:

    DG=sparse(E(:,1),E(:,2),W);
    

    希望这能解决您的问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-11-06
      • 1970-01-01
      • 1970-01-01
      • 2021-02-27
      • 1970-01-01
      • 2011-01-16
      • 2011-03-30
      • 1970-01-01
      相关资源
      最近更新 更多