def find_all_paths(graph, start, end, path=):
        path = path + 
        if start == end:
            return 
        if not graph.has_key(start):
            return 
        paths = 
        for node in graph:
            if node not in path:
                newpaths = find_all_paths(graph, node, end, path)
                for newpath in newpaths:
                    paths.append(newpath)
        return paths
麻烦帮忙翻译成java语言的,  没法翻译的地方麻烦帮忙加点注释, 非常感谢

解决方案 »

  1.   

    关键是懂matlab程序才能翻译啊。这语法不是很懂
      

  2.   

    matlab可以自己帮你转的
    具体的步骤忘了是什么了,你在网上找找吧
    matlab会帮你把matlab代码转为java代码,并封装成jar
      

  3.   


    String find_all_paths(Graph graph, Node start, Node end, Path path=){ //path=是个什么??
             path = path + // 这句又是个什么,matlab里可以这么写?
             if (start == end)
                 return ;
             if (!graph.has_key(start))
                 return ;
             paths = //同上
             for( node in graph.nodes) // 理解为foreach,循环遍历graph里的所有节点
               {  if (!path.has(node))
                 {
                     newpath = find_all_paths(graph, node, end, path);
                     for ( newpath in newpaths )
                           paths.append(newpath);
                  }
              }
              return paths;
    }
    写是可以这么写,但是有很多问题
    Graph,Node,Path都是自定义的类,和matlab里的类是一样的
    而且,其他的操作,如“=”,两个Node对象相等,这个得自己定义等等
    我都想不明白,为啥要翻译呢?