存储为元组列表的图形。元组的第一个元素 - 顶点,第二个元素元组 - 与之连接的顶点。
我要连接的headName-vertex [:t=Srting]**
我要连接的元素-vertises [:t=List]**
A可以连接顶点所以[(1,[2]),(2,[])],但我想连接所以[(1,[2]),(2,[1])]。有点做了,但不起作用。怎么了?请帮忙。
connect_command graph headName []=(graph,"You didnt enter elements to connect!\n")
connect_command graph headName elements=
if (has_element graph headName) then ((update_connect graph graph headName elements []),"Element "++headName++" connected with "++listToString (checked_elements graph headName elements []) []++"\n")
else (graph,"Element with "++headName++" name not found!")
update_connect _ [] _ _ result=result
update_connect mainGraph (item:graph) headName (i:elements) result=
if ((fst item)==headName) then (update_connect mainGraph graph headName elements (result++[((fst item),(checked_elements mainGraph headName elements []))]))
else if ((fst item)==i) then (update_connect mainGraph graph headName (i:elements) (result++[((fst item),[headName])]))
else (update_connect mainGraph graph headName elements (result++[item]))
checked_elements _ _ [] result=result
checked_elements graph headName (item:elements) result=
if (has_element graph item)&& (item /=headName)then checked_elements graph headName elements (result++[item])
else (checked_elements graph headName elements result)
headName-我要连接的顶点*[:t=Srting]*
我要连接的元素-vertises*[:t=List]*