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
trouble to help translate the java language , unable to translate local trouble to help add a little comment, thank you very much
------ Solution ---------- ----------------------------------
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;
}
write is so written , but there are a lot of problems
Graph, Node, Path is a custom class , and the matlab class is the same
Also, other operations , such as " =" , two Node objects are equal, so this was their definition
I wanted to do not understand why you want to translate it ?
------ For reference only -------------------------------------- -
key is to understand the matlab program to translate ah. This syntax is not very good
------ For reference only ---------------------------------- -----
matlab can help you turn yourself
concrete steps to forget what it is , you look for it online
matlab matlab code will help you put into java code, and packaged into a jar
------ For reference only ------------------ ---------------------
Thank you very much
没有评论:
发表评论