【问题标题】:Graph Theory: Find the Jordan center?图论:找到乔丹中心?
【发布时间】:2009-11-27 08:18:56
【问题描述】:

我正在尝试找到一组顶点,以最大限度地减少它们与加权图上其他顶点的距离。根据粗略的维基百科搜索,我认为这被称为Jordan Center。有什么好的算法可以找到它?

现在,我的计划是获取从给定顶点发出的每个分支的权重列表。权重相对差异最小的顶点将是中心顶点。还有其他想法吗?

我正在使用 Java,但有用的答案不一定需要特定于 Java。

【问题讨论】:

    标签: java language-agnostic graph-theory jgrapht


    【解决方案1】:

    我会首先使用Dijkstra algorithm(它必须为每个verticle运行)来计算所有verticle对之间的最短距离——还有一些更有效的算法,比如Floyd-Warshall。然后对于每个顶点 V,您必须找到 Vm - 从 Dijkstra 算法返回的数据中到任何其他顶点的 最大 距离。然后,具有最小 Vm 的顶点是图形中心的顶点。伪代码:

    int n = number of verticles;
    int[][] D = RunDijkstraOrWarshall()
    // D[a,b] = length of shortest path from a to b
    int[] Vm = new int[n];
    for(int i=0; i<n i++)
    {
       Vm[i] = 0
       for(int j=0; j<n; j++) 
       {
         if (Vm[i] < D[i,j]) Vm[i] = D[i,j];
       }  
    }
    
    minVm = int.Max;
    for(int i=0; i<n ;i++)
    {
      if (minVm < Vm[i]) minVm = Vm[i];
    }
    
    for(int i=0; i<n ;i++)
    {
      if (Vm[i] == minVm)
      {
         // graph center contans i
      }
    

    }

    【讨论】:

    • 我相信你的意思是检查“if (Vm[i]
    • 除了你需要做的改变......很好的解释:-)。代码可以稍微清理一下,但它很好地说明了概念并解释了你用文字写的内容:-)。 +1。
    • 感谢您发现这一点,我刚刚进行了更正。上述算法可以直接合并到 Dijksta 或 Floyd-Warshal 中,以避免运行额外的 for 循环(无论如何,Dijkstra 必须遍历顶点)。
    【解决方案2】:

    本硕士论文介绍了图中心问题的三种算法:A distributed algorithm for the graph center problem

    【讨论】:

      【解决方案3】:

      从 JGraphT 版本 1.1.0 开始,您可以简单地使用方法GraphMeasurer.getGraphCenter()。底层代码使用最短路径方法。用户可以根据图的某些特征(例如稀疏/密集/...)来选择使用哪种方法。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-03-23
        • 1970-01-01
        • 1970-01-01
        • 2015-01-27
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多